velimir

zgradi

Apr 5th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int x, y=-1, z, final=0;
  8.     cin >> x;
  9.     int niza[x];
  10.     for(int i=0; i<x; i++) cin >> niza[i];
  11.     for(int j=0; j<x; j++)if(niza[j]>y)y=niza[j];
  12.     for(int k=0; k<x; k++)
  13.     {
  14.         while(niza[k]<y)
  15.         {
  16.             final++;
  17.             niza[k]++;
  18.         }
  19.     }
  20.     cout << final;
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment