本站遷移

因為我最近租用了網路空間以及網域,
故本站已遷移至新網站~
這邊的資訊已經正在進行搬移的工作~
希望各位可以到新網站去逛XD

New Website:
http://knightzone.org/

搜尋此網誌

2011年1月18日 星期二

[Zerojudge]a005: Eva 的回家作業

找出所給陣列的規律究竟是等比還是等差,
之後即可找出第五個值。

[C++](2ms, 706KB)
#include<iostream>
using namespace std;
int main()
{
int t;
while( cin >> t )
{
for( int i = 0 ; i < t ; i++ )
{
int array[5] = {0};
for( int j = 0 ; j <= 3 ; j++ )
{
cin >> array[j];
cout << array[j] << ' ';
}
if( array[1] - array[0] == array[2] - array[1] )
cout << array[3] + array[1] - array[0];
else
cout << array[3] * array[1] / array[0];
cout << endl;
}
}
return 0;
}

0 意見:

張貼留言