Срочно.заданный одномерный массив А (8). Найти количество положительных элементов массива. С++
40 балов
Ответы на вопрос
Ответил MA3EIN
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 года назад
Русский язык,
6 лет назад
Физика,
8 лет назад