![](https://i-blog.csdnimg.cn/blog_migrate/1431271034e8aa757f887a44f6c3ab9c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/d11550aceea90a1cf3f7086143894f31.png)
#define _crt_secure_no_warnings
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <stdio.h>
void main()
{
int num;
void orderarray(int a[], int num);
void printfarray(int a[], int num);
printf("please input the data\n");
int a[] = { 33, 44, 22, 3, 2, 5, 99, 809, 879};
num = sizeof(a) / sizeof(a[0]);
printf("num:%d\n", num);
printf("排序之前\n");
printfarray(a, num);
printf("排序之后\n");
orderarray(a, num);
printfarray(a, num);
system("pause");
return;
}
{
int num;
void orderarray(int a[], int num);
void printfarray(int a[], int num);
printf("please input the data\n");
int a[] = { 33, 44, 22, 3, 2, 5, 99, 809, 879};
num = sizeof(a) / sizeof(a[0]);
printf("num:%d\n", num);
printf("排序之前\n");
printfarray(a, num);
printf("排序之后\n");
orderarray(a, num);
printfarray(a, num);
system("pause");
return;
}
void orderarray(int a[],int num)
{
int i, j, temp;
for (i = 0; i < num; i++)
{
for (j = i + 1; j < num; j++)
{
if (a[i]>a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
//return a;
}
void printfarray(int a[], int num)
{
int i, j, temp;
for (i = 0; i < num; i++)
{
for (j = i + 1; j < num; j++)
{
if (a[i]>a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
//return a;
}
void printfarray(int a[], int num)
{
int i;
for (i = 0; i < num; i++)
{
printf("%d ",a[i]);
}
printf("\n");
return;
}
int i;
for (i = 0; i < num; i++)
{
printf("%d ",a[i]);
}
printf("\n");
return;
}