公衆號【C you again】回覆 「浙大版C語言」 查看每道題目詳細實現思路 編程
公衆號【C you again】回覆 「編程交流羣」 進C/C++/Java編程題交流、問題解答羣 學習
按照規定,在高速公路上行使的機動車,達到或超出本車道限速的10%則處200元罰款;若達到或超出50%,就要吊銷駕駛證。請編寫程序根據車速和限速自動判別對該機動車的處理。spa
輸入格式:設計
輸入在一行中給出2個正整數,分別對應車速和限速,其間以空格分隔。code
輸出格式:遊戲
在一行中輸出處理意見:若屬於正常行駛,則輸出「OK」;若應處罰款,則輸出「Exceed x%. Ticket 200」;若應吊銷駕駛證,則輸出「Exceed x%. License Revoked」。其中x是超速的百分比,精確到整數。開發
輸入樣例1:get
65 60源碼
輸出樣例1:io
OK
輸入樣例2:
110 100
輸出樣例2:
Exceed 10%. Ticket 200
輸入樣例3:
200 120
輸出樣例3:
Exceed 67%. License Revoked
代碼:
#include<stdio.h> int main() { int m; //車速 int n; //限速 scanf("%d %d",&m,&n); int t1=n+n*0.1; int t2=n+n*0.5; // printf("%d %d\n",t1,t2); if(m<t1) printf("OK\n"); if(m>=t1&&m<t2) { double temp1=(m-n)/(double)n*100.0; double temp2=temp1-(int)temp1; int temp; if(temp2>=0.5) temp=(int)temp1+1; else temp=(int)temp1; printf("Exceed %d%%. Ticket 200\n",temp); } if(m>=t2) { double temp1=(m-n)/(double)n*100.0; double temp2=temp1-(int)temp1; int temp; if(temp2>=0.5) temp=(int)temp1+1; else temp=(int)temp1; printf("Exceed %d%%. License Revoked\n",temp); } }