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(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);
}
}