题目
高速公路超速处罚
计算好 超出10%和50%的数值
在用车速去比较
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void speed(int sped,int res);
int main()
{
int a,b;
scanf("%d %d",&a ,&b);
speed(a,b);
getchar();
getchar();
return 0;
}
void speed(int sped,int res)
{
float perc;
if( sped < res*1.1)
{
printf("OK");
}else {
perc = (sped - res) / (res*1.0)*100;
if( sped >= res*1.1 && sped < res*1.5 )
{
printf("Exceed %0.f%%. Ticket 200", perc);
}else {
printf("Exceed %0.f%%. License Revoked", perc);
}
}
}
吐槽一下这题 精确到整数 把我弄傻了 我以为整数就直接用int了 没想到最后还是要float