码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2014-06-18 14:04:59      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:style   class   blog   code   color   strong   

 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 }

 测试通过

分支-08. 高速公路超速处罚,布布扣,bubuko.com

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

标签:style   class   blog   code   color   strong   

原文地址:http://www.cnblogs.com/boomkeeper/p/B8.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!