求助大佬
求助,,,,大佬谁能帮看看,到底哪里出问题了?20多分钟编完代码,然后就一直一直调试,自己的ide里运行的好好地,一复制过来就不行了,,,心态爆炸,等反应过来的时候剩不到20分钟,弄得第二道题都没心情做。。。。
import java.util.Scanner;
public class LLLL {
public static void main(String[] args) {
Scanner sc1=new Scanner(System.in);
int num=sc1.nextInt();
if(num<3||num>1000000) {
System.out.println("无法判断!");
System.exit(-1);
}
Scanner sc2=new Scanner(System.in);
int []a=new int [num] ;
for(int i=0;i<num;i++) {
a[i]=sc2.nextInt();
}
int specialweight;
int location=0;
if(a[0]==a[1]&&a[1]==a[2]&&a[0]==a[2]) {
specialweight=a[1];
}
else if(a[0]!=a[1]&&a[0]==a[2]) {
specialweight=a[0];
}
else if(a[0]!=a[2]&&a[0]==a[1]) {
specialweight=a[1];
}
else {
specialweight=a[1];
}
if(specialweight>1000000){
System.out.println("质量超标!");
System.exit(-1);
}
for(int i=0;i<num;i++) {
if(specialweight!=a[i]) {
location=i+1;
}
}
System.out.println(location);
}
}
查看12道真题和解析
字节跳动公司福利 1377人发布
