`
bcyy
  • 浏览: 1827346 次
文章分类
社区版块
存档分类
最新评论

九度教程第1题

 
阅读更多

题目地址:http://ac.jobdu.com/problem.php?cid=1040&pid=0

C语言源码:

#include<stdio.h>
int main()
{
	int a[100],i,j,n,x;
	while(scanf("%d",&n)!=EOF)
	{
		for(i=0;i<n;i++)
			scanf("%d",&a[i]);
		for(i=0;i<n-1;i++)
		{
			for(j=0;j<n-1-i;j++)
			{
				if(a[j]>a[j+1])
				{
					x=a[j];
					a[j]=a[j+1];
					a[j+1]=x;
				}
			}
		}
		i=0;
		while(i<n)
			printf("%d ",a[i++]);
		printf("\n");
	}
}


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics