#include<iostream>
#include<cmath>
using namespace std;
int main(){
int a,b,c,d,i;
int x,y,z,p,q,r;
int t;
cin>>t;
if(t==0)
cout<<"0";
for (i=1;i<=t;i++) {
cin>>a>>b>>c>>d;
x=b-a;
y=c-b;
z=d-c;
p=b/a;
q=c/b;
r=d/c;
if(x==y && y==z){
cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<d+x<<endl;
}
if(p==q && q==r){
cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<d*p<<endl;
}
}
system("pause");
return 0;
}
他說錯誤:1 1 1 1 1
正確:2 4 6 8 10
WA:Line4
但是我用2 4 6 8 10測都沒問題呀
誰能幫幫我?
#include
#include
using namespace std;
int main(){
int a,b,c,d,i;
int x,y,z,p,q,r;
int t;
cin>>t;
if(t==0)
cout<<"0";
for (i=1;i<=t;i++) {
cin>>a>>b>>c>>d;
x=b-a;
y=c-b;
z=d-c;
p=b/a;
q=c/b;
r=d/c;
if(x==y && y==z){
cout<<<" "<<<" "<<<" "<<<" "<<
}
if(p==q && q==r){
cout<<<" "<<<" "<<<" "<<<" "<<
}
}
system("pause");
return 0;
}
他說錯誤:1 1 1 1 1
正確:2 4 6 8 10
WA:Line4
但是我用2 4 6 8 10測都沒問題呀
誰能幫幫我?
當他輸入1 1 1 1時,
既是等差也是等比,
但是你兩個都用if,
造成會輸出兩次1 1 1 1 1!