Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 18th, 2011  |  syntax: C  |  size: 0.98 KB  |  views: 53  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include<stdio.h>
  2. //#include<conio.h>
  3.  
  4.  
  5.  
  6. int main()
  7. {
  8.     int games, flag= 1 , i, lead = 0, score1, score2, diff,temp1,temp2;
  9.    
  10.    
  11.     scanf("%d",&games);
  12.     for(i = 1 ; i<= games;i++)
  13.     {
  14.           scanf("%d%d", &score1, &score2);
  15.           score1 = score1 + temp1;
  16.           score2 = score2 + temp2;
  17.           if(score1 > score2)
  18.           {
  19.                     diff = score1 - score2;
  20.                     if(diff > lead)
  21.                     {
  22.                             lead = diff;
  23.                             flag = 1;
  24.                     }
  25.            
  26.           }
  27.           else
  28.           {
  29.               diff = score2 - score1;
  30.               if(diff > lead)
  31.                     {
  32.                             lead = diff;
  33.                             flag = 2;
  34.                     }
  35.           }
  36.           temp1 = score1;
  37.           temp2 = score2;
  38.           //printf("%d  %d  %d  %d  %d\n",temp1,temp2,flag, diff, lead);  
  39.        
  40.     }
  41.    
  42.     printf("%d %d",flag, lead);
  43.    
  44.     return 0;
  45. }
clone this paste RAW Paste Data