Предмет: Информатика,
автор: tsadanbvc3223
Срочно.заданный одномерный массив А (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;
}
Похожие вопросы
Предмет: Английский язык,
автор: Помогите12234
Предмет: Английский язык,
автор: milekhina81
Предмет: Русский язык,
автор: математика502
Предмет: История,
автор: даник1231234567890