#include "stdafx.h" #include <iostream> #include <ctime> using namespace std;
int main(void) { setlocale(LC_ALL, "Russian"); srand(time(0)); const int SIZE = 300; int arr[SIZE]; int SUM = 0; cout << "Случайные числа: \n"; for (int i = 0; i < SIZE; i++) { arr[i] = rand() % 40 - 20; cout << arr[i] << endl; } for (int i = 0; i < SIZE; i++) SUM += arr[i]; cout << "Сумма равна :" << SUM << endl;
#include <iostream>
#include <ctime>
using namespace std;
int main(void)
{
setlocale(LC_ALL, "Russian");
srand(time(0));
const int SIZE = 300;
int arr[SIZE];
int SUM = 0;
cout << "Случайные числа: \n";
for (int i = 0; i < SIZE; i++)
{
arr[i] = rand() % 40 - 20;
cout << arr[i] << endl;
}
for (int i = 0; i < SIZE; i++)
SUM += arr[i];
cout << "Сумма равна :" << SUM << endl;
system("pause");
return 0;
}