PAT基础编程题目-7-8 超速判断

PAT基础编程题目-7-8 超速判断

题目详情

题目地址:https://pintia.cn/problem-sets/14/problems/788

解答

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");
		}

	}

}

创作不易,喜欢的话加个关注点个赞,谢谢谢谢谢谢!

全部评论

相关推荐

吃不饱的肱二头肌很想退休:tnnd 我以为选妹子呢,亏我兴高采烈的冲进来😠
投递快手等公司10个岗位
点赞 评论 收藏
分享
dongsheng66:如果想进大厂的话,在校经历没必要占这么大篇幅,可以把专业技能单独放一个专栏写,可以加个项目经历
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务