分支-08. 高速公路超速处罚

 1 /*
 2  *B8-分支-08. 高速公路超速处罚(15)
 3  * Main.c
 4  *  Created on: 2014年5月28日
 5  *      Author: Boomkeeper
 6  */
 7 
 8 #include <stdio.h>
 9 #include <stdlib.h>
10 
11 int main()
12 {
13     int speed,topspeed;
14     int *ps=&speed;
15     int *pt=&topspeed;
16 
17     scanf("%i %i",&speed,&topspeed);
18 
19     if(*ps<0 || *pt<0)
20         exit(0);
21 
22     int overtoppercent=(int)(((double)(speed-topspeed)/topspeed)*100+0.5);//计算超速百分比,只保留整数
23 
24     if(overtoppercent<10)
25     {
26         printf("OK\n");
27     }
28 
29     if(overtoppercent<50 && overtoppercent>=10)
30     {
31         printf("Exceed %i%%. Ticket 200\n",overtoppercent);
32     }
33 
34     if(overtoppercent>=50)
35     {
36         printf("Exceed %i%%. License Revoked\n",overtoppercent);
37     }
38 
39     return 0;
40 }

 测试通过

posted @ 2014-06-16 19:53  Boomkeeper  Views(420)  Comments(0Edit  收藏  举报
最好的流量统计 网站流量计数器