#include <iostream>
using namespace std;
int main()
{
int a,b,c,d,i,t;
cin>>t;
if(0<=t<=20){
for(i=0;i<t;i++)
while(cin>>a>>b>>c>>d)
if(d-c==c-b==b-a)
{cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<d+c-b<<endl;
}
else
{cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<d*(d/c)<<endl;
}
}
return 0;
}
為什麼d-c==c-b==b-a
輸入2 4 6 8結果為2 4 6 8 8
但是打成d-c==c-b就可以了
#include
using namespace std;
int main()
{
int a,b,c,d,i,t;
cin>>t;
if(0<=t<=20){
for(i=0;i<t;i++)
while(cin>>a>>b>>c>>d)
if(d-c==c-b==b-a)
{cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<d+c-b<<endl;
}
else
{cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<d*(d/c)<<endl;
}
}
return 0;
}
為什麼d-c==c-b==b-a
輸入2 4 6 8結果為2 4 6 8 8
但是打成d-c==c-b就可以了
if (條件1 && 條件2)
所以應該是這樣 if(d-c == c-b && c-b == b-a)