Помогите написать программу на C++
Приложения:

Ответы на вопрос
Ответил clinteastwood2
0
Если бы надо было сделать через вектор, а не обычный массив, было бы ещё проще.
#include <iostream>
#include <random>
#include <ctime>
using namespace std;
mt19937 gen { random_device()() };
uniform_int_distribution<> uid(1, 100); // диапазон от 1 до 100
int main()
{
int a[15];
int count = 0;
for (auto &i : a) {
i = uid(gen);
cout << i << " ";
if (i % 5 == 0 && i > 30) {
count++;
}
}
cout << endl << "Count: " << count;
return 0;
}
Ответил ЯковПервый
0
#include <iostream>
using namespace std;
int main()
{
int A[15];
int MasVal = 1;
int counter = 0;
for (int i = 0; i < 15; i++)
{
A[i] = MasVal;
MasVal = MasVal + 1;
}
for (int j = 0; j < 15; j++)
{
if (A[j] % 5 == 0 && A[j] > 30)
counter = counter + 1;
}
cout << " Kolichestvo chisel: " << counter << endl;
return 0;
}
using namespace std;
int main()
{
int A[15];
int MasVal = 1;
int counter = 0;
for (int i = 0; i < 15; i++)
{
A[i] = MasVal;
MasVal = MasVal + 1;
}
for (int j = 0; j < 15; j++)
{
if (A[j] % 5 == 0 && A[j] > 30)
counter = counter + 1;
}
cout << " Kolichestvo chisel: " << counter << endl;
return 0;
}
Новые вопросы