#include <iostream>
using namespace std;
int main()
{
int t;
int w;
int x;
int y;
int z;
cin >> t;
while ( t>0 ) {
cin >> w >> x >> y >> z;
if( z-y == y-x == x-w ) {
cout << w << " " << x << " " << y << " " << z << " " << z+y-x << endl;
}
else {
cout << w << " " << x << " " << y << " " << z << " " << z*y/x << endl;
}
t--;
}
return 0;
}
請問上面有出什麼問題嗎?
#include
using namespace std;
int main()
{
int t;
int w;
int x;
int y;
int z;
cin >> t;
while ( t>0 ) {
cin >> w >> x >> y >> z;
if( z-y == y-x == x-w ) {
cout << w << " " << x << " " << y << " " << z << " " << z+y-x << endl;
}
else {
cout << w << " " << x << " " << y << " " << z << " " << z*y/x << endl;
}
t--;
}
return 0;
}
請問上面有出什麼問題嗎?
若是輸入"2 3 5 7",則不應該輸出"2 3 5 7 11",應該輸出1個錯誤訊息(因為前4項為2,3,5,7不是等差數列,也不是等比數列)