欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

PAT基础编程题目-7-9 用天平找小球

程序员文章站 2022-06-07 09:58:20
...

PAT基础编程题目-7-9 用天平找小球

题目详情

PAT基础编程题目-7-9 用天平找小球

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

解答

C语言版

#include<stdio.h>
int main() {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a == b)
		printf("C");
	else if (a == c)
		printf("B");
	else if (b == c)
		printf("A");
	return 0;
}

PAT基础编程题目-7-9 用天平找小球

C++版

#include<iostream>
int main() {
	int a, b, c;
	std::cin >> a >> b >> c;
	if (a == b)
		std::cout << "C";
	else if (a == c)
		std::cout << "B";
	else if (b == c)
		std::cout << "A";
	return 0;
}

PAT基础编程题目-7-9 用天平找小球

Java版

import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		int a = 0,b = 0,c = 0;
		Scanner scanner = new Scanner(System.in);
		if (scanner.hasNext()) {
			a = scanner.nextInt();
			b = scanner.nextInt();
			c = scanner.nextInt();
		}
		scanner.close();
		
		if (a == b) {
			System.out.println("C");
		}
		if (a == c) {
			System.out.println("B");
		}
		if (b == c) {
			System.out.println("A");
		}

	}

}

PAT基础编程题目-7-9 用天平找小球

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