PAT基础编程题目-7-8 超速判断
PAT基础编程题目-7-8 超速判断
题目详情
解答
C语言版
#include<stdio.h>
int main()
{
int speed;
scanf("%d", &speed);
if (speed <= 60)
printf("Speed: %d - OK", speed);
if (speed > 60)
printf("Speed: %d - Speeding", speed);
return 0;
}
C++版
#include<iostream>
int main()
{
int speed;
std::cin >> speed;
if (speed <= 60)
std::cout << "Speed: " << speed << " - OK";
if (speed > 60)
std::cout << "Speed: " << speed << " - Speeding";
return 0;
}
Java版
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
int speed=0;
Scanner scanner = new Scanner(System.in);
if (scanner.hasNext()) {
speed = scanner.nextInt();
}
scanner.close();
if (speed<=60) {
System.out.println("Speed: "+speed+" - OK");
}
else {
System.out.println("Speed: "+speed+" - Speeding");
}
}
}
创作不易,喜欢的话加个关注点个赞,谢谢谢谢谢谢!