带3个数字的java打印3个不同的大小写
int a、b、c
Scanner scan = new Scanner(System.in);
System.out.println("Inserire a");
a = scan.nextInt();
System.out.println("Inserire b");
b = scan.nextInt();
System.out.println("Inserire c");
c = scan.nextInt();
if (a == b && a == c){
System.out.println("All the same");
}
if (((a==b) && b!=c) || ((a==c) && (b!=c)) || ((b == c) && (a!= c)));
{
System.out.println("Two the same and one different ");
}
else
{
System.out.print(" All different");
}
else if (( a != b) && (b != c) && (a != c));
{
System.out.println("Tutti diversi");
}
扫描。close(); }
我得到了else的错误,程序读取了所有3种不同的情况 然后打印出3张照片
# 1 楼答案
你必须这样做,因为在同一块的else后面加上else if会给你带来麻烦。如果这不是你想要的行为,请提供更多信息,我会尽力帮助:)
# 2 楼答案
尝试使用else if,而不是第二个if,在所有else if之后粘贴else部分