2013
11-10

# Eva’s Problem

Eva的家庭作业里有很多数列填空练习。填空练习的要求是：已知数列的前四项，填出第五项。因为已经知道这些数列只可能是等差或等比数列，她决定写一个程序来完成这些练习。

2
1 2 3 4
1 2 4 8

1 2 3 4 5
1 2 4 8 16

//* @author 洪晓鹏<[email protected]/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */>
import java.util.Scanner;

public class Main {
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int n = in.nextInt();
for(int i = 0; i < n; i++)
{
int one = in.nextInt();
int two = in.nextInt();
int three = in.nextInt();
int four = in.nextInt();
int d1 = two - one;
int d2 = three - two;
int d3 = four - three;
if((d1 == d2)&&(d3 == d2))
{
int five = four + d1;
System.out.println(one+" "+two+" "+three+" "+four+" "+five);
}
else
{
int five = four * (two/one);
System.out.println(one+" "+two+" "+three+" "+four+" "+five);
}
}
}
}

1. Thanks for using the time to examine this, I truly feel strongly about it and enjoy finding out far more on this subject matter. If achievable, as you achieve knowledge

2. 很高兴你会喜欢这个网站。目前还没有一个开发团队，网站是我一个人在维护，都是用的开源系统，也没有太多需要开发的部分，主要是内容整理。非常感谢你的关注。