#include <iostream>
using namespace std;
int main(int argc, char** argv){
int a[3],b,c,d;
for(int i=1; i<=b; i++)
cin>>a[0]>>a[1]>>a[2]>>a[3];
c=a[3]-a[2];
d=a[2]-a[1];
if(c==d){
d=a[3]+c;
cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<" "<<a[3]<<" "<<d;
}
else{
c=a[3]/a[2];
d=a[2]/a[1];
d=a[3]*c;
cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<" "<<a[3]<<" "<<d;
}
}
b = ? //沒定義
a[3]不存在 //int a[3] ; -> a[0]~a[2] ,a[3]超出範圍
我猜你是想寫↓吧(?
#include <iostream>
using namespace std;
int main(int argc, char** argv){
int t, a[4], d;
cin >> t;
for(int i = 1; i <= t; i++){
cin >> a[0] >> a[1] >> a[2] >> a[3];
if((a[2]-a[1]) == (a[1]-a[0])){
d = a[3] + (a[3]-a[2]);
}
else{
d = a[2] * (a[2]/a[1]);
}
cout << a[0] << " " << a[1] << " " << a[2] << " " << a[3] << " " << d << "\n";
}
}