Find the ball with a balance

Find the ball with a balance

Three balls A, B, C, which has the same size and shape of a ball with other balls of different weight. We asked to identify the different balls.

Input format:
input given positive integer 3 in a row, the ball corresponding to the order A, B, C, wt.

Output formats:
Output only the different balls in a row.

Sample input:
112

Sample output:
C
C language

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

java language

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
         int A,B,C;
        Scanner reader=new Scanner(System.in);
        A=reader.nextInt();
        B=reader.nextInt();
        C=reader.nextInt();
        if(A==B&&C!=A)
            System.out.printf("C");
        else if(A==C&&A!=B)
        	System.out.printf("B");
        else if(B==C&&B!=A)
        	System.out.printf("A");
    }
}
Released seven original articles · won praise 1 · views 114

Guess you like

Origin blog.csdn.net/weixin_45714844/article/details/104094154