同上
------解决方案--------------------------------------------------------
3个数,2个相同,输出不同?附上代码。。。
- Java code
import java.util.Scanner;public class Demo{ public static void main(String[] args) { System.out.print("请输入三个数:"); Scanner in = new Scanner(System.in); int x = in.nextInt(); int y = in.nextInt(); int z = in.nextInt(); //判断相同,输出不同的数 if(x == y) System.out.println(z); if(x == z) System.out.println(y); if(y == z) System.out.println(x); }}
------解决方案--------------------------------------------------------
- Java code
import java.util.Scanner;public class Test1 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); int arr[] = new int[3]; System.out.println("请输入3个数:"); for(int i = 0; i < 3; i++) { arr[i] = in.nextInt(); } for(int i = 1; i < 3; i++) { if(arr[0] != arr[i]) { System.out.println("不相同的数是:"+arr[i]); } } }}