C语言入门 数组的应用问题
#include<stdio.h>
int main()
{
int shengao[] = { 172,163,179,180,165,168,172 };
int q , r;
for (q = 6; q>= 0; q--)
{
for (r = 0; r <= q; r++)
{
if (shengao[r] > shengao[r + 1])
{
int temp;
temp = shengao[r];
shengao[r] = shengao[r + 1];
shengao[r + 1] = temp;
}
}
}
for (q = 0; q < 7; q++)
{
if (q != 6)
{
printf("%d,", shengao[q]);
}
else
{
printf("%d\n", shengao[q]);
}
}
return 0;
}