#7010: 為什麼呢???


rodwin (rodwin)


 #include<iostream>
using namespace std;

int main()
{
    int t,a[4];
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        for(int j=0;j<=3;j++)
            cin>>a[j];
        if((a[1]-a[0])==(a[2]-a[1]))
        {
            a[4]=a[3]+(a[3]-a[2]);
            for(int k=0;k<=4;k++)
                cout<<a[k]<<" ";
            cout<<endl;
        }
        else
        {
            a[4]=a[3]*a[3]/a[2];
            for(int k=0;k<=4;k++)
                cout<<a[k]<<" ";
            cout<<endl;
        }
    }
}


不行  ,   會有WA錯誤 
 
 
 
 
#include<iostream>
using namespace std;

int main()
{
    int t,a,b,c,d,e;
    cin>>t;
        while(t-->0)
        {
        cin>>a>>b>>c>>d;
        if((c-b)==(b-a))
        {
            e=d+d-c;
            cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;
        }
        else
        {
            e=d*d/c;
            cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;
            cout<<endl;
        }
        }
    }
}
 
就可以!!!!!!!!!!!! 

請各位幫幫忙><

#7012: Re:為什麼呢???


passerr (20130326 0340 48)


大概是陣列的問題吧

a[4]的範圍 0 1 2 3

你有用到a[4]