Advertisement
AngelLIves

Поменять макс и номер 1

Nov 21st, 2018
482
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <climits>
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n;
  7.     cin >> n;
  8.     int *a = new int[n];
  9.     int count;
  10.     int max = INT_MIN;
  11.     for(int i = 0 ; i<10 ; i++){
  12.         cin >> a[i];
  13.         if (a[i]>max){
  14.             max=a[i];
  15.             count = i;
  16.         }
  17.     }
  18.     a[count]=a[1];
  19.     a[1]=max;
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement