8/01/2013

11764 - Jumping Mario - UVA

  1. #include<iostream>
  2. using namespace std;
  3. int main ()
  4. {
  5.         int arr[50];
  6.         int testCases ;
  7.         int N;
  8.        
  9.         cin>>testCases;
  10.         for(int i=0; i<testCases ; i++){
  11.                 cin>>N;
  12.                 int ups = 0 , downs = 0; //counters
  13.                 for(int ii=1; ii<=N; ii++){
  14.                         cin>>arr[ii];
  15.                 }
  16.                 for(int j=1; j<N; j++){
  17.                         if(arr[j]<arr[j+1])
  18.                                 ++ups;
  19.                     if(arr[j]>arr[j+1])
  20.                                 ++downs;
  21.                         if(arr[j] == arr[j+1])
  22.                                 continue;
  23.                         }
  24.        
  25.                
  26.                 cout<<"Case "<<i+1<<": "<<ups<<" "<<downs<<endl;
  27.         }
  28.         return 0;
  29. }


    You can find more of my solutions on
     Here

No comments:

Post a Comment