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 |
无语In Reply To:Re:敢情你的计算概论和程序实习全逃课了?char c[3]算什么东西?后面的'\0'装哪儿去? Posted by:00 at 2005-07-09 00:09:03 #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[4]; 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 ((int *)arg1)[0]-((int*)arg2)[0]; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator