Advertisement
sheredega

Task #11

Dec 10th, 2022
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n;
  7.     cout << "Enter the number of array: ";
  8.     cin >> n;
  9.     int* array = new int [n];
  10.     int max;
  11.     cout << "Enter the numbers:\n";
  12.     for (int i = 0; i < n; i ++) {
  13.         cin >> array[i];
  14.         if (i == 0) {
  15.             max = array[i];
  16.         }
  17.         else if (max < array[i]) {
  18.             max = array[i];
  19.         }
  20.     }
  21.     cout << "\nYour array: ";
  22.     for (int i = 0; i < n; i++) {
  23.         cout << array[i] << " ";
  24.     }
  25.     cout << "\nMax number of array: " << max;
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement