Syntax error on token "else", delete this token求助大神,怎么改?
importjava.util.Scanner;publicclassMain{publicstaticvoidmain(Stringargs[]){Scannersc=...
import java.util.Scanner;
public class Main {
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
if(n>10&&n<100){
for(int s=10000;s<=999999;s++){
int a=s/100000;
int b=s/10000%10;
int c=s/1000%10;
int d=s/100%10;
int e=s/10%10;
int f=s%10;
if(((a+b+c+d+e+f==n)&&((a==f)&&(b==e)&&(c==d)))||(((a==0)&&(b+c+d+e+f==n))&&((b==f)&&(c==e)))){
System.out.println(s);
}
}
else
{
System.out.println("-1");
}
}
}
} 展开
public class Main {
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
if(n>10&&n<100){
for(int s=10000;s<=999999;s++){
int a=s/100000;
int b=s/10000%10;
int c=s/1000%10;
int d=s/100%10;
int e=s/10%10;
int f=s%10;
if(((a+b+c+d+e+f==n)&&((a==f)&&(b==e)&&(c==d)))||(((a==0)&&(b+c+d+e+f==n))&&((b==f)&&(c==e)))){
System.out.println(s);
}
}
else
{
System.out.println("-1");
}
}
}
} 展开
展开全部
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if (n>10 && n<100) {
for (int s = 10000; s <= 999999; s++) {
int a = s / 100000;
int b = s / 10000 % 10;
int c = s / 1000 % 10;
int d = s / 100 % 10;
int e = s / 10 % 10;
int f = s % 10;
if (((a + b + c + d + e + f == n) && ((a == f) && (b == e) && (c == d))) || (((a == 0) && (b + c + d + e + f == n)) && ((b == f) && (c == e)))) {
System.out.println(s);
}
}
}
else {
System.out.println("-1");
}
}
}
追问
我一个怎么改?没看出来啊,泪奔
追答
不客气
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询