分支-05. 用天平找小球
2014-09-12 16:59
197 查看
三个球A、B、C,大小形状相同且其中有一个球与其他球重量不同。要求找出这个不一样的球。
输入格式:输入在一行中给出3个正整数,顺序对应球A、B、C的重量。
输出格式:在一行中输出唯一的那个不一样的球。
输入样例:1 1 2输出样例:C
输入格式:输入在一行中给出3个正整数,顺序对应球A、B、C的重量。
输出格式:在一行中输出唯一的那个不一样的球。
输入样例:1 1 2输出样例:C
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner ball = new Scanner(System.in); String balls = ball.nextLine(); String[] b = balls.split(" "); if(b.length == 3) { int b1 = Integer.parseInt(b[0]); int b2 = Integer.parseInt(b[1]); int b3 = Integer.parseInt(b[2]); if(b1==b2 || b1==b3 || b2==b3) { if(b1==b2) System.out.print("C"); else { if(b1==b3) System.out.print("B"); else System.out.print("A"); } } else System.out.print("Input error!"); } } }
相关文章推荐
- 分支-05. 用天平找小球(10)
- 分支-05 用天平找小球(10)
- 分支-05. 用天平找小球(10)
- 分支-05. 用天平找小球(10)
- 分支-05. 用天平找小球(10)
- 分支-05. 用天平找小球(10)
- 分支-05. 用天平找小球(10)
- 分支-05. 用天平找小球
- 分支-05. 用天平找小球
- 分支程序设计05 - 零基础入门学习C语言14
- 03-2. 用天平找小球(10)
- 用天平找小球
- Git常用命令速查05 - 分支与标签
- 12个球,外形相同,其中有一个球重量与其余11球不同,如何使用天平尽量少次数的测量找出这个小球且判别它比正常球轻还是重
- 无砝码天平3次称出12个小球中质量异常球问题
- 分支程序设计05 - 零基础入门学习C语言14
- 05.GitHub实战系列~5.发布版本之分支操作+Tag讲解 2015-12-14
- 3-2. 用天平找小球(10)
- pat(从分支-05开始)
- Java基础笔记整理---【05】switch分支语句、for循环语句