Напишите программу поиска максимального элемента в числовом массиве из 30 различных элементов.

Ответы

Ответ дал: Mishka28
0
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;

int main()
{
    srand (time(0));
    int a[30];
    for (int i=0; i<30; i++)
    {
        a[i]=rand()%30+1;
        cout <<a[i] <<' ';
    }
    cout <<endl;
    int max = 0;
    for (int i=1; i<30; i++)
      max = (a[i]>a[max]) ? i:max;
    cout <<a[max] <<endl;
    return 0;
}
Вас заинтересует