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 yangguo98l at 2006-11-21 22:29:03 on Problem 2371
In Reply To:Why time limit exceed Posted by:baichen at 2006-08-31 21:30:52
> 
> #include<stdio.h>
> #include<string.h>
> main()
> {int t,i,j,w;
>  long n;
>  int a[1000001],b[101];
>  char s[5];
> //The input of the database
>  scanf("%d",&n);
>  for(i=1;i<=n;i++)
>    scanf("%d",&a[i]);
> 
>  scanf("%s",s);
>  //The input of the query
>  scanf("%d",&t);
>  for(i=1;i<=t;i++)
> 	 scanf("%d",&b[i]);
>  //冒泡法排序
>  for(i=1;i<=n-1;i++)
> 	 for(j=1;j<=n-i;j++)
> 		 if(a[j]>a[j+1])
> 		 {w=a[j];
> 		  a[j]=a[j+1];
> 		  a[j+1]=w;
> 		 }
>   //The output
>   for(i=1;i<=t;i++)
> 	  printf("%d\n",a[b[i]]);
>   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