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

Re:错在何处?请高手指正!

Posted by zby03 at 2004-10-17 18:00:18 on Problem 1552
In Reply To:错在何处?请高手指正! Posted by:ibm at 2004-04-25 20:34:20
> #include<iostream.h>
> #include<stdio.h>  
> void QuickSort(int x[],int low,int high);
> 
> void QuickSort(int x[],int low,int high)
> {
> 	  int i,j;
> 	  int Temp;
> 
> 	  i=low;
> 	  j=high;
> 	  Temp=x[low];
> 
> 	  while(i<j)
> 	  {
> 		  while(i<j&&Temp<=x[j])  
> 			  j--;
> 		  if(i<j)
> 		  {
> 			  x[i]=x[j];
> 			  i++;
> 		  }
> 		  while(i<j&&x[j]<=Temp) 
> 			  i++;
> 		  if(i<j)
> 		  {
> 			  x[j]=x[i];
> 			  j--;
> 		  }
> 	  }
> 	  x[i]=Temp;
> 
> 	  if(low<i-1)QuickSort(x,low,i-1);
> 	  if(j+1<high)QuickSort(x,j+1,high);
> }
> 
> void main()
> {
> 	int a[100][100];
> 	int i,j,k,n;
> 	j=0;
> 	do{ 
> 		i=0;
> 		while(i<101)
> 		{
> 		  cin>>a[j][i];
> 		  if(a[j][i]<=0||a[j][i]==-1) break;
> 		  else i++;
> 		}
>         if(i)
> 			QuickSort(a[j],0,i-1);
> 		if(a[j][0]!=-1)
> 			j++;
> 		else break;
> 	}while(1);
> 	for(k=0;a[k][0]!=-1;k++)
> 	{
> 		n=i=0;
> 		while(a[k][i])
> 		{
> 			for(j=i+1;a[k][j]!=0;j++)
> 			{
> 				if(2*a[k][i]==a[k][j])
> 				{
> 					n++;
> 					break;
> 				}
> 			}
> 			i++;
> 		}
> 		cout<<n<<endl;
> 	}
> }
> 
> 

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