Подсчитать сумму элементов массива, значения которых кратны 8.
#include
#include
using namespace std;
int main()
{
const int size = 80;
int matrix[size];
int sum = 0;
srand(time(NULL));
for (int i = 0; i < size; i++){
matrix = 1 + rand() % 80;
cout << matrix << " ";
}
system("pause");
for (int i = 0; i < size; i++){
cout << matrix << endl;
sum += matrix;
}
if (matrix % 8 = 0)
{
cout << "Summa: " << sum << endl;
}
system("pause >> NULL");
return 0;
}
#include
#include
using namespace std;
int main()
{
const int size = 80;
int matrix[size];
int sum = 0;
srand(time(NULL));
for (int i = 0; i < size; i++){
matrix = 1 + rand() % 80;
cout << matrix << " ";
}
system("pause");
for (int i = 0; i < size; i++){
cout << matrix << endl;
sum += matrix;
}
if (matrix % 8 = 0)
{
cout << "Summa: " << sum << endl;
}
system("pause >> NULL");
return 0;
}