| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
WHY WA?超级菜鸟恳请各位高手指点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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator