#include<stdio.h>
void bubble_sort(int *a,int n)
{
	int i,j;
	for(i = 0;i<n;i++)
	{
		for(j = i;j < n;j++)
		{
			if(*(a+i)>*(a+j))
			{
				int temp;
				temp = *(a+i);
				*(a+i) = *(a+j);
				*(a+j) = temp;
			}
		}
	}
/*	for(i = 0;i < n;i++)
	{
		printf("%d\t",*(a+i));
	}
*/
}
void print(int *a,int n)
{
	int i;
	for(i = 0;i < n;i++)
	{
		printf("%d\t",*(a+i));
	}
	printf("\n");
}
int main()
{
	int a[5];
	int i;
	for(i = 0;i < 5;i++)
	{
		scanf("%d",&a[i]);
	}
	bubble_sort(a,5);
	print(a,5);
	return 0;
}


相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-22
  • 2021-05-01
  • 2021-09-13
  • 2021-06-29
猜你喜欢
  • 2022-12-23
  • 2021-08-22
  • 2021-11-28
  • 2022-12-23
  • 2021-10-19
  • 2021-11-22
  • 2021-11-06
相关资源
相似解决方案