#include <iostream>
using namespace std;
int main()
{
int t,a[20],b[20],c[20],d[20];
cin>>t;
for(int n=0;n<t;n++)
cin>>a[n]>>b[n]>>c[n]>>d[n];
for(int i=0;i<t;i++){
cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<" "<<d[i]<<" ";
if(d!=(c*2)) cout<<d+(d-c)<<endl;
else cout<<d*2<<endl;
}
return 0;
}
弄四個陣列是因為程式要一次打完所有題目再一次輸出答案
改成這樣
#include <iostream>
using namespace std;
int main()
{
int t,n,i;
int a[21],b[21],c[21],d[21];
for(n=0;n<t;n++)
cin>>a[n]>>b[n]>>c[n]>>d[n];
for(i=0;i<t;i++){
cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<" "<<d[i]<<" ";
if(d[i]!=(c[i]*2)) cout<<d[i]+(d[i]-c[i])<<endl;
else cout<<d[i]*2<<endl;
}
return 0;
}
變成輸出短少