冒泡排序小到大,第二位有错误
#include<stdio.h>int main()
{
int a[80];
int i, j;
int n;
int t;
printf_s("请输入一共有几个数");
scanf_s("%d", &n);
for (i = 0; i < n; i++)
{
scanf_s("%d", &a[i]);
}
for (i = 0; i < n-1; i++)
{
for (j = 0; j > n-i; ++)
{
if (a[j]>a[j+1])
{
t = a[j];
a[j] = a[j+1];
a[j+1] = t;
}
}
}
for (i = 0; i < n; i++)
{
printf_s("%d\t", a[i]);
}
return 0;
}