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

敢情你的计算概论和程序实习全逃课了?char c[3]算什么东西?后面的'\0'装哪儿去?

Posted by frkstyc at 2005-07-08 23:38:28 on Problem 2371
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:
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