| ||||||||||
| 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 | |||||||||
用冒泡还是超时啊.....盼指点In Reply To:谁能告诉我这道题该怎做啊?TLE Posted by:8304536 at 2006-07-05 11:33:39 #include<stdio.h>
main()
{
int sum;
scanf("%d",&sum);
int a[100];
int i,j,t;
int n;
int count;
int z;
for(z=0;z<sum;z++)
{
scanf("%d",&n);
for(i=0;i<100;i++)
a[i]=0;
for(i=0;i<n;i++)
scanf("%d",&a[i]);
count=0;
for(j=0;j<n;j++)
{
for(i=0;i<n-j-1;i++)
if(a[i]>a[i+1])
{
t=a[i];
a[i]=a[i+1];
a[i+1]=t;
count++;
}
}
printf("Scenario #%d:\n",z+1);
printf("%d\n",count);
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator