[解题报告]Zapping

题目大意

题目原文:http://uva.onlinejudge.org/external/124/12468.pdf

背景

计算电视转台问题,太简单不说了。自己看吧。

                

             
standard input
standard output
   
3                             9                                                         

0                                99                                                            

12                                27                                                            

-1                                -1                                                              

6                                                         

1                                                            

15

算法:

很简单的算法。自己看看。

代码:

这里附上我的代码,你可以去这里提交你的代码验证你的代码是否正确。

 1 #include<stdio.h>
 2 int main(void)
 3 {
 4     int a,b,c,d;
 5     while(scanf("%d %d",&a,&b)!=EOF)
 6     {
 7        if(a==-1&&b==-1)break;
 8 
 9        c=a-b;
10        d=b-a;
11 
12        if(c<0)
13        c=100+c;
14        if(d<0)
15        d=100+d;
16        if(c>d)
17        printf("%d\n",d);
18        else
19        printf("%d\n",c);
20     }
21     return 0;
22 }

 

posted @ 2013-02-20 18:54  乱七八糟 。  阅读(157)  评论(0编辑  收藏  举报