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 jinbi at 2008-10-26 21:01:29 on Problem 1147
#include<stdio.h>
int a[3001],next[3001],b[3001];
int main()
{
    int n,n1,n0,i,j,k;
    while(scanf("%d",&n)!=EOF)
    {      n1=0;  n0=0;
           for(i=0;i<n;i++)
           {     scanf("%d",&a[i]);
                 if(a[i]==1) n1++;
                 else n0++;
           }
           i=0; j=n0;
           for(k=0;k<n;k++)
           {     if(a[k]==0) next[i++]=k;
                 else next[j++]=k;
           }
           //for(i=0;i<n;i++)
             //printf("%d ",next[i]); 
           for(i=0;i<n-1;i++)
               printf("%d ",a[next[i]]);
           printf("%d\n",a[next[n-1]]);
    }
    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