Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

各位牛人,我的各个数据都对,怎么过不了

Posted by 04105330 at 2008-03-31 22:38:10 on Problem 3032
#include<iostream>

using namespace std;

int main()
{
        int z,n,m,i,j,d;

        cin >> n;

        while(n--)
        {
                cin >> m;
                i = 1;
                int  a[13] ={0};
                d = 1;
                j = 1;
                while(j<=m)
                {
                        if(m ==1)       a[0] = j;
                        else if(d ==1&&m!=1)    a[i] = j,       d = 2;
                        else if(d==2)
                        {
                                z = 0;
                                while(z<=2){            i = (i+1)%m;

                                if(a[i] == 0)   z++;
                                                        }
                                a[i] = j;
                                d = 3;
                        }
                        else if(d == 3)
                        {
                                z = 0;
                                while(z<=3)
                                {       i = (i+1)%m;
                                        if(a[i] == 0)
                                z++;

                                }


                                a[i] = j;
                                d = 4;
                        }
                        else if(d == 4)
                        {
                                z = 0;
                                while(z<=4)
                                {
                                        i = (i+1)%m;
                                        if(a[i] == 0)
                                z++;

                                }


                                a[i] = j;

                        }


                        j++;

                }

                for( i = 0; i < m; i++)
                        cout << a[i] <<" ";
                cout << endl;
        }

        return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator