超速判断

超速判断

模拟交通警察的雷达测速仪。输入汽车速度,如果速度超出60 mph,则显示“Speeding”,否则显示“OK”。

输入格式:
输入在一行中给出1个不超过500的非负整数,即雷达测到的车速。

输出格式:
在一行中输出测速仪显示结果,格式为:Speed: V - S,其中V是车速,S或者是Speeding、或者是OK。

输入样例1:
40

输出样例1:
Speed: 40 - OK

输入样例2:
75

输出样例2:
Speed: 75 - Speeding
c语言

#include<stdio.h>
int main()
{
    int speed;
    scanf("%d",&speed);
    if(speed>60)
    printf("Speed: %d - Speeding",speed);
    else
    printf("Speed: %d - OK",speed);
    return 0;
}
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
         int speed;
        Scanner reader=new Scanner(System.in);
        speed=reader.nextInt();
        if(speed>60)
        	System.out.printf("Speed: %d - Speeding",speed);
        else
        	System.out.printf("Speed: %d - OK",speed);
    }
}
发布了7 篇原创文章 · 获赞 1 · 访问量 116

猜你喜欢

转载自blog.csdn.net/weixin_45714844/article/details/104093863