avrora26
31.05.2020 22:41

Конспект о общих сведения о форматировании

Нажмите на рекламу ниже и сразу увидите ответ
Популярные вопросы:
Ответ:
05061972
10.03.2020 08:11
#include <iostream>
#include <cstdlib>#include <ctime>
using namespace std;

int main() {
srand(time(0));
const int n = 5;
int x[n], y[n], x0=0, y0=0;
for (int i = 0; i < n; ++i) {
x[i] = rand() % 5;
y[i] = rand() % 5;}
for (int i = 0; i < n; ++i) {
cout<< x[i]<<' ';}
cout << endl;
for (int i = 0; i < n; ++i) {cout << y[i] << ' ';}
for (int i = 0; i < n; ++i) {
if (x[i]) x0++;
if (y[i]) y0++;}
cout << endl;
if (x0 > y0) cout << 'x';
if (x0 < y0) cout << 'y';
if (x0 == y0) cout << '='; 
return 0;}
0,0(0 оценок)
Ответ:
susannamuratov1
23.12.2021 21:31
#include <cstdlib>
#include <ctime> 
#include <iostream>

using namespace std;

int main() {
    int n=10, i, s=0;
    int a[n];
    srand(time(NULL));
    cout<<"array:"<<endl;
    for (i=0; i<n; i++)
    {
      a[i]=rand() % 50;
      cout<<a[i]<<"  ";
    }
    cout<<endl;
        i = 1;
    do {
    a[i] = a[i]*a[i];
    s += a[i];
    i += 2;
    } while (i<=n);
    
    for (i=0; i<n; i++) cout<<a[i]<<" ";
    cout<<endl;
    cout << "s = " << s << endl;
    return(0);
}

Пример:
array:
39 10 25 35 9 14 29 34 24 41
39 100 25 1225 9 196 29 1156 24 1681
s = 4358
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота