Exercise 3-2 motorway speeding penalties (15 points)

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 formats:

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

Output formats:

In line output 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

answer:

#include<stdio.h>
int main(){
    double speed,limit,x;
    scanf("%lf%lf",&speed,&limit);
    if(speed<limit*1.1){
        printf("OK");
    }else if(speed>=limit*1.1 && speed<limit*1.5){
        x = (speed-limit)/limit*100;
        printf("Exceed %.0lf%%. Ticket 200",x);
    }else{
        x = (speed-limit)/limit*100;
        printf("Exceed %.0lf%%. License Revoked",x);
    }
    return 0;
}

 

Published 98 original articles · won praise 2 · Views 3738

Guess you like

Origin blog.csdn.net/qq_30377869/article/details/104753895