#include <iostream>
#include <vector>
#include <random>
#include <ctime>
using namespace std;
void solve(){
srand(time(NULL));
const int N = 10;
vector<int> a(N), d(N + 1, 0);
for(int i = 0; i < N; i++){
a[i] = rand() % 100 + 1;
d[i + 1] = d[i] + a[i];
cout << a[i] << " ";
}
int firstIndex = -1, lastIndex = -1;
if(!(a[i] & 1)){
if(firstIndex < 0)
firstIndex = i;
lastIndex = i;
cout << "\n" << d[lastIndex + 1] - d[firstIndex];
int main(){
solve();
Поделитесь своими знаниями, ответьте на вопрос:
Создайте таблицу размером 2х3 и раскрастье её по столбцам в разные цвета НЕ ПРОХОДИТЕ МИМО
#include <iostream>
#include <vector>
#include <random>
#include <ctime>
using namespace std;
void solve(){
srand(time(NULL));
const int N = 10;
vector<int> a(N), d(N + 1, 0);
for(int i = 0; i < N; i++){
a[i] = rand() % 100 + 1;
d[i + 1] = d[i] + a[i];
cout << a[i] << " ";
}
int firstIndex = -1, lastIndex = -1;
for(int i = 0; i < N; i++){
if(!(a[i] & 1)){
if(firstIndex < 0)
firstIndex = i;
lastIndex = i;
}
}
cout << "\n" << d[lastIndex + 1] - d[firstIndex];
}
int main(){
solve();
}