#include<stdio.h>
void fun (int *str, int len)
{
for (int i = 0; i < len-1; i++)
{
for (int j = 0; j < len-1-i; j++)
{
if (str[j] > str[j + 1])
{
int temp = str[j];
str[j] = str[j + 1];
str[j + 1] = temp;
}
}
}
for (int i = 0; i < len; i++)
{
printf("%d",str[i]);
}
}
int main()
{
int len;
int str[] = { 1,5,6,2,3,4,8,9,7 };
len = sizeof(str) / sizeof(str[0]);
fun(str, len);
}
11-03
07-10
07-10
07-10
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交