您的答案為: 1 2 4 8 -107751 ...略 正確答案為: 1 2 4 8 16
#include <iostream> using namespace std; int main() { int a1,a2,a3,a4,b1,b2,b3,b4; int series[5]; float D; while(cin >> D >> b1 >> b2 >> b3 >> b4 >> a1 >> a2 >> a3 >> a4){ series[b1-1] = a1; series[b2-1] = a2; series[b3-1] = a3; series[b4-1] = a4; if (series[1] - series[0] == D & series[2] - series[1] == D & series[3] - series[2] == D){ series[4] = series[3] + D; } else if (series[1] / series[0] == D & series[2] / series[1] == D & series[3] / series[2] == D){ series[4] = series[3] * D; } for (int i = 0; i < 5; i++) cout << i+1 << " " ; cout << endl; for (int i = 0; i < 5; i++) cout << series[i] << " "; cout << endl; } return 0; }
您的答案為: 1 2 4 8 -107751 ...略 正確答案為: 1 2 4 8 16
#include using namespace std;
int main() {
int a1,a2,a3,a4,b1,b2,b3,b4;
int series[5];
float D;
while(cin >> D >> b1 >> b2 >> b3 >> b4 >> a1 >> a2 >> a3 >> a4){
series[b1-1] = a1;
series[b2-1] = a2;
series[b3-1] = a3;
series[b4-1] = a4;
if (series[1] - series[0] == D & series[2] - series[1] == D & series[3] - series[2] == D){
series[4] = series[3] + D;
}
else if (series[1] / series[0] == D & series[2] / series[1] == D & series[3] / series[2] == D){
series[4] = series[3] * D;
}
for (int i = 0; i < 5; i++)
cout << i+1 << " " ;
cout << endl;
for (int i = 0; i < 5; i++)
cout << series[i] << " ";
cout << endl;
}
return 0; }
}