Срочно.заданный одномерный массив А (8). Найти количество положительных элементов массива. С++
40 балов
Ответы
Ответ дал:
0
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <time.h>
#include <stdio.h>
#include<math.h>
#include <tgmath.h>
using namespace std;
int main() {
srand(time(0));
const int n=8;
int a[n];
int k=0;
for(int i=0;i<n;i++)
{
a[i]=-50+rand()%100;
cout << setw(5)<<a[i];
if(a[i]>0)k++;
}
cout << endl;
cout << "k=" <<k;
}
#include <iomanip>
#include <cstdlib>
#include <time.h>
#include <stdio.h>
#include<math.h>
#include <tgmath.h>
using namespace std;
int main() {
srand(time(0));
const int n=8;
int a[n];
int k=0;
for(int i=0;i<n;i++)
{
a[i]=-50+rand()%100;
cout << setw(5)<<a[i];
if(a[i]>0)k++;
}
cout << endl;
cout << "k=" <<k;
}
Вас заинтересует
2 года назад
2 года назад
8 лет назад
8 лет назад
9 лет назад