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

高手帮我看一下!!!!!!!!!!为什么是RUNTIME ERROR!!

Posted by liu0412 at 2011-08-30 19:23:13 on Problem 1833
#include <stdio.h>
#define N 1025
int main()
{
	int i, j, m, t, n, k, a[N];
	scanf("%d", &m);;
	while( m-- )
	{
		scanf("%d %d", &n, &k);
		for( i = 0; i < n; i++ )
			scanf("%d", &a[i]);
		for( i = n-2 ; k;  )
		{
			for( j = n-1; j > i; j--)
				if( a[i] < a[j] )
				{
					t = a[i];
					a[i] = a[j];
					a[j] = t;

					j = n-1;
					i++;
					for( ; i<j; j--, i++)
					{
						t = a[i];
						a[i] = a[j];
						a[j] = t;
					}
					i = n-2;
					j = n-1;
					k--;
					break;
				}

				if(i == 0&&j == 0)
				{
					j = n-1;
					for( ; i<j; i++, j--)
					{
						t = a[i];
						a[i] = a[j];
						a[j] = t;
					}
					i = n-2;
					j = n-1;
					k--;
				}
				
				else
					if(i == j)
						i--;		
		}
		for(i = 0; i < n; i++)
			printf("%d ", a[i]);
		printf("\n");
	}
	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