juanjo12x

UVA_10550_Combination_Lock

May 21st, 2014
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(int argc, char** argv) {
  5.     int a,b,c,d;int temp;int sm;
  6.     while(scanf("%d %d %d %d",&a,&b,&c,&d) ){
  7.         if ((a==0) && (b==0) &&(c==0) &&(d==0)){
  8.             break;
  9.         }
  10.         sm=1080;
  11.         /*horario*/
  12.         temp=a-b;
  13.         if (temp<0) temp=temp+40;
  14.         sm=sm+9*temp;
  15.         /*antihorario*/
  16.         temp=c-b;
  17.         if (temp<0) temp=temp+40;
  18.         sm=sm+9*temp;
  19.         /*horario*/
  20.         temp=c-d;
  21.         if (temp<0) temp=temp+40;
  22.         sm=sm+9*temp;
  23.         printf("%d\n",sm);
  24.     }
  25.     return (EXIT_SUCCESS);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment