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 iammk at 2009-03-31 16:18:48 on Problem 1833
#include<iostream>
using namespace std;
void search(int array[],int n)
{
	int i,j;
	int k,k1,k2;
	int temp;
	for(k=2;k<n;k++) 
		if(array[k-1]<array[k]&&k>1) //找到最后的循序数字
			i=k;
		if(i>1)
		{
			j=1;
			for(k=i;k<=n;k++) 
				if(array[i-1]<array[k]&&k>1) 
					j=k; 
			temp=array[j];
			array[j]=array[i-1];
			array[i-1]=temp;
			 for(k1=i,k2=n-1;k1<k2;k1++,k2--) 
			 { 
				 temp=array[k1]; 
				 array[k1]=array[k2]; 
				 array[k2]=temp; 
			 }
		}
		else 
		{ 
			for(i=1;i<n;i++) 
				array[i]=i; //最后一组数组,回到起始位置
		} 
}
int main()
{
	int n,k,i;
	int count;
	int *array;
	cin>>count;
	while(count--)
	{
		scanf("%d%d",&n,&k);
		array=new int[n+1];
		for(i=1;i<=n;i++)
			scanf("%d",&array[i]);
		while(k>0)
		{
			search(array,n+1);
			k--;
		}
		for(i=1;i<=n;i++)
			printf("%d ",array[i]);
		printf("\n");
	}
	delete array;
	return 0;
}我这个为什么过不了?(wrong answer)请帮帮看看

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