Практика 3 задание 1

PHOTO EMBED

Sun Oct 06 2024 16:59:58 GMT+0000 (Coordinated Universal Time)

Saved by @Yakostoch

#include <iostream>
using namespace std;
int main() {
    int mx;
    int mx_num;
    int t{};
    std::cout <<"Enter desired max of the array: ";
    std::cin >> mx;
    int *array = new int[mx];
    cout << "Enter your numbers: " << endl;
    
    int i{};
    while (i < mx)
    {
        cin >> array[i];
        
        if(t < 1)
        {
            mx_num = array[i];    
            t++;   
        }
    
        i++;
    }

    for(i = 0; i < mx; i++)
    {
        cout << array[i] << "\t";
    }
    
    for(i = 0; i < mx; i++)
    {
        if(array[i] > mx_num)  
        {
            mx_num = array[i];    
        }
    }
    
    cout << endl;
    cout << "Максимальное число последовательности: " << mx_num << endl;
    cout <<  endl;
}
content_copyCOPY