PTA | "C Programming Language (3rd Edition)" Exercise 3-2 motorway speeding penalties (15 points)

topic

According to regulations, the exercise of a motor vehicle on the highway, lane speed limit is reached or exceeded 10% of the fine of 200 yuan; If you reach or exceed 50%, will be revoked driver's license. Please write processing of the program is automatically determined based on the vehicle speed and the vehicle speed.

Input format:
input given in row two positive integers, respectively, corresponding to the vehicle speed and the speed limit, separated by a space therebetween.

Output formats:
Output in line Disposition: It's normal driving, the output "OK"; if should be fine, the output "Exceed x% Ticket 200." ; If should be revoked driver's license, the output "Exceed x%. License Revoked ". Where x is the percentage of speed to the nearest integer.

Sample Input 1:

65 60

Output Sample 1:

OK

Sample Input 2:

110 100

Output Sample 2:

Exceed 10%. Ticket 200

Sample Input 3:

200 120

Sample Output 3:

Exceed 67%. License Revoked

Reference Solution

#include<stdio.h>
int main(){
    int speed,lim;
    scanf("%d %d",&speed,&lim);
    if(speed*10<lim*11){
    	printf("OK");
    }
    else if(speed*10>=lim*11&&speed*10<lim*15){
    	printf("Exceed %.0f%%. Ticket 200",100.0*(speed-lim)/lim);
    }
    else if(speed*10>=lim*15){
    	printf("Exceed %.0f%%. License Revoked",100.0*(speed-lim)/lim);
    }
    return 0;
}
Published 33 original articles · won praise 5 · Views 1524

Guess you like

Origin blog.csdn.net/weixin_44421292/article/details/104210033