Написать эту программу в с++ даны два массива а и в одинакового размера n. сформировать новый массив с того же размера, каждый элемент которого равен максимальному из элементов массивов а и в с тем же индексом. program project1; {$apptype console} var a: array[1..100] of integer; b: array[1..100] of integer; c: array[1..100] of integer; i,n: integer; begin write ('n (1..100): '); readln(n); randomize; for i: =1 to n do begin a[i]: = random(10); b[i]: = random(10); if a[i]> b[i] then c[i]: =a[i] else c[i]: =b[i]; end; write('a[]: '); for i: =1 to n do write(a[i], '; '); writeln; write('b[]: '); for i: =1 to n do write(b[i], '; '); writeln; write('c[]: '); for i: =1 to n do write(c[i], '; '); readln; end.

Дарья20099 Дарья20099    2   05.08.2019 10:10    0

Ответы
tanamakagonova tanamakagonova  03.10.2020 23:16
#include<iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
int main()
{
int i, N;
int a[100];
int b[100];
int c[100];
cout << "N(1..100): " << endl;
cin >> N;
srand(time(NULL));
 for (i = 1; i <= N; i++)
{
 a[i] = rand() % 10;
 b[i] = rand() % 10;
 if (a[i] > b[i]) c[i] = a[i];
 else c[i] = b[i];
}
cout << "a[]: ";
 for (i = 1; i <= N; i++)
 {
  cout << a[i]<<" ";
 }
  cout<<endl;
 cout << "b[]: ";
 for (i = 1; i <= N; i++)
 {
  cout << b[i] << " ";
 }
 cout << endl;
 cout << "c[]: ";
for (i = 1; i <= N; i++)
 {
  cout << c[i] << " ";
 }
 cout << endl;

system("pause");
 return 0;
}
ПОКАЗАТЬ ОТВЕТЫ
Другие вопросы по теме Информатика