#11219: #JAVA-Eclipse測試正常,解題卻出現錯誤,請神人解答


ss0935565 (morning)

學校 : 朝陽科技大學
編號 : 58733
來源 : [163.17.21.136]
最後登入時間 :
2019-04-19 16:52:30
a005. Eva 的回家作業 -- POJ | From: [1.165.78.208] | 發表日期 : 2016-07-30 15:52

Scanner scanner = new Scanner(System.in); int a=0,b=0,c=0,d=0,e=0,t=0; int[] ary = new int[4]; t=scanner.nextInt(); while(t0){ for(int j=0;j<t;j++){ for(int i=0;i<ary.length;i++){ ary[i]=scanner.nextInt(); if(i==3){ a=ary[1]-ary[0]; b=ary[2]-ary[1]; c=ary[3]-ary[2]; if(a==b &&b==c){ d=ary[3]+c; break; }else{ a=ary[1]/ary[0]; b=ary[2]/ary[1]; c=ary[3]/ary[2]; if(a==b && b==c){ e=ary[3]*c; break; } } } } } System.out.println(ary[0] + " " + ary[1] + " " + ary[2] + " " + ary[3] + " " + d); if(t>1){ System.out.println(ary[0] + " " + ary[1] + " " + ary[2] + " " + ary[3] + " " + e); } }

 
#11220: Re:#JAVA-Eclipse測試正常,解題卻出現錯誤,請神人解答


ss0935565 (morning)

學校 : 朝陽科技大學
編號 : 58733
來源 : [163.17.21.136]
最後登入時間 :
2019-04-19 16:52:30
a005. Eva 的回家作業 -- POJ | From: [1.165.78.208] | 發表日期 : 2016-07-30 15:56

Scanner scanner = new Scanner(System.in); int a=0,b=0,c=0,d=0,e=0,t=0; int[] ary = new int[4]; t=scanner.nextInt(); while(t0){ for(int j=0;j<t;j++){ for(int i=0;i<ary.length;i++){ ary[i]=scanner.nextInt(); if(i==3){ a=ary[1]-ary[0]; b=ary[2]-ary[1]; c=ary[3]-ary[2]; if(a==b &&b==c){ d=ary[3]+c; break; }else{ a=ary[1]/ary[0]; b=ary[2]/ary[1]; c=ary[3]/ary[2]; if(a==b && b==c){ e=ary[3]*c; break; } } } } } System.out.println(ary[0] + " " + ary[1] + " " + ary[2] + " " + ary[3] + " " + d); if(t>1){ System.out.println(ary[0] + " " + ary[1] + " " + ary[2] + " " + ary[3] + " " + e); } }

*更正*

    Scanner scanner = new Scanner(System.in);

    int a=0,b=0,c=0,d=0,e=0,t=0;

    int[] ary = new int[4];

    t=scanner.nextInt();

   

    while(t<20 &&t>0){

    for(int j=0;j<t;j++){

    for(int i=0;i<ary.length;i++){

    ary[i]=scanner.nextInt();

    if(i==3){

    a=ary[1]-ary[0];

    b=ary[2]-ary[1];

    c=ary[3]-ary[2];

    if(a==b &&b==c){

    d=ary[3]+c;

    break;

    }else{

    a=ary[1]/ary[0];

    b=ary[2]/ary[1];

    c=ary[3]/ary[2];

    if(a==b && b==c){

    e=ary[3]*c;

    break;

    }

    }

    }

    }

    }

    System.out.println(ary[0] + " " + ary[1] + " " + ary[2] + " " + ary[3] + " " + d);

    if(t>1){

    System.out.println(ary[0] + " " + ary[1] + " " + ary[2] + " " + ary[3] + " " + e);

    }

    }

    

 
ZeroJudge Forum