杭电acm2535我哪里错了 网址http://acm.hdu.edu.cn/showproblem.php?pid=2535
#include<stdio.h>intmain(){intn,a[200],i,j,t,sum;while(scanf("%d",&n)!=EOF&&n){sum=0;...
#include<stdio.h>
int main()
{
int n,a[200],i,j,t,sum;
while(scanf("%d",&n)!=EOF&&n)
{
sum=0;
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
for(i=1;i<=n;i++)
{
for(j=i;j<=n-1;j++)
{
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
n=n/2+1;
for(i=1;i<=n;i++)
sum=sum+a[i]/2+1;
printf("%d\n",sum);
}
return 0;
} 展开
int main()
{
int n,a[200],i,j,t,sum;
while(scanf("%d",&n)!=EOF&&n)
{
sum=0;
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
for(i=1;i<=n;i++)
{
for(j=i;j<=n-1;j++)
{
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
n=n/2+1;
for(i=1;i<=n;i++)
sum=sum+a[i]/2+1;
printf("%d\n",sum);
}
return 0;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询