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 |
敢情你的计算概论和程序实习全逃课了?char c[3]算什么东西?后面的'\0'装哪儿去?In Reply To:why wrong answer? Posted by:00 at 2005-07-08 23:25:59 > #include<iostream.h> > #include<stdlib.h> > int compare(const void *arg1,const void *arg2); > void main() > { > long N,i; > cin>>N; > int *d=new int[N]; > for(i=0;i<N;i++) > cin>>d[i]; > qsort(d,N,sizeof(int),compare); > char c[3]; > cin>>c; > int K,q; > cin>>K; > for(i=0;i<K;i++) > { > cin>>q; > cout<<d[q-1]<<endl; > } > delete [] d; > } > int compare(const void *arg1,const void *arg2) > { > return ((char *)arg1)[0]-((char*)arg2)[0]; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator