PAT基础编程题目-7-9 用天平找小球
程序员文章站
2022-06-07 09:58:20
...
PAT基础编程题目-7-9 用天平找小球
题目详情
解答
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;
}
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;
}
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");
}
}
}
创作不易,喜欢的话加个关注点个赞,谢谢谢谢谢谢!