除了1,2,3,4,5這組答案可以成功之外,沒有其他的成功
請各位學長高手們解惑
#include<iostream>
using namespace std;
int main()
{
int a;
cin>>a;
for(int i=1;i<=a;i++)
{
int a1,a2,a3,a4;
cin>>a1>>a2>>a3>>a4;
if(a4/a3==a3/a2==a2/a1)
cout<<a1<<" "<<a2<<" "<<a3<<" "<<a4<<" "<<a4*(a4/a3)<<endl;
if(a4-a3==a3-a2==a2-a1)
cout<<a1<<" "<<a2<<" "<<a3<<" "<<a4<<" "<<(a4+a4-a3)<<endl;
}
return 0;
}
除了1,2,3,4,5這組答案可以成功之外,沒有其他的成功
請各位學長高手們解惑
#include
using namespace std;
int main()
{
int a;
cin>>a;
for(int i=1;i<=a;i++)
{
int a1,a2,a3,a4;
cin>>a1>>a2>>a3>>a4;
if(a4/a3==a3/a2==a2/a1)
cout<<a1<<" "<<a2<<" "<<a3<<" "<<a4<<" "<<a4*(a4/a3)<<endl;
if(a4-a3==a3-a2==a2-a1)
cout<<a1<<" "<<a2<<" "<<a3<<" "<<a4<<" "<<(a4+a4-a3)<<endl;
}
return 0;
}
if 中間改成if(a4/a3==a3/a2&&a3/a2==a2/a1)
另一個也是一樣
除了1,2,3,4,5這組答案可以成功之外,沒有其他的成功
請各位學長高手們解惑
#include
using namespace std;
int main()
{
int a;
cin>>a;
for(int i=1;i<=a;i++)
{
int a1,a2,a3,a4;
cin>>a1>>a2>>a3>>a4;
if(a4/a3==a3/a2==a2/a1)
cout<<a1<<" "<<a2<<" "<<a3<<" "<<a4<<" "<<a4*(a4/a3)<<endl;
if(a4-a3==a3-a2==a2-a1)
cout<<a1<<" "<<a2<<" "<<a3<<" "<<a4<<" "<<(a4+a4-a3)<<endl;
}
return 0;
}
if 中間改成if(a4/a3==a3/a2&&a3/a2==a2/a1)
另一個也是一樣
如果前面成立 就會回傳1 然後就變成if(1==a2/a1) 自然就不對了