题解:尽管题目是输入正整数,但是最好是换成浮点数会方便很多。先算出差值,再用if-else。在printf中表示百分号的方法:%%由于要精确到整数,所以printf中采用 %.0f。
#include <stdio.h>
int main()
{
float speed, max, x;
scanf("%f %f", &speed, &max);
x = (speed - max) / max * 100; //时速与限速的差值。
if (x >= 50)
printf("Exceed %.0f%%. License Revoked\n", x);
else if (x >= 10)
printf("Exceed %.0f%%. Ticket 200\n", x);
else
printf("OK\n");
return 0;
}