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

WHY WA?超级菜鸟恳请各位高手指点

Posted by shangji685 at 2006-08-11 16:22:31 on Problem 1804
In Reply To:没加任何优化的冒泡都能过 Posted by:huicpc21 at 2006-07-27 10:29:11
>  
#include<stdio.h>
main()
{
	int i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		int j,k,temp,count=0,m;
		long int a[1002];
		scanf("%d",&m);
		for(j=0;j<m;j++)
			scanf("%i",&a[j]);
		for(j=0;j<m;j++)
		{	for(k=j;k<m;k++)
			{
				if(a[j]>a[k])
				{
					temp=a[k];
					a[k]=a[j];
					a[j]=temp;
					count++;
				}
              
			}
		}
		printf("Scenario #%d:\n",i+1);
		printf("%d\n\n",count);
	}
}

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