Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:请教只排一次序的算法,我排了两次,1xxxMSIn Reply To:Re:请教只排一次序的算法,我排了两次,1xxxMS Posted by:Huacm56 at 2006-07-27 12:34:27 > 不用排序的算法 > #include<stdio.h> > int re[10010]={0}; > int main() > { int N,D,C,i,j,sum,max,right=0,result; > while(scanf("%d",&N)&&N) > { for(i=0;i<10010;i++) > re[i]=10010; > sum=0;result=1; > for(i=0;i<N;i++) > { scanf("%d%d",&D,&C); > if(re[D]>C) re[D]=C; > if(right<D) right=D; > } > i=0; > while(re[i]==10010) i++; > max=re[i]; > for(j=i+1;j<=right;j++) > if(re[j]<max) > {result++;max=re[j];} > printf("%d\n",result); > } > return 0; > } 46MS Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator