//冒泡排序
#include<stdio.h>
//内存分配函数需加载的头文件
#include<stdlib.h>
//定义顺序表结构类型
typedef struct
{
//数据域
int *data;
//长度
int length;
}List;
//冒泡排序
void order(List &L)
{
//i j for循环遍历索引
int i,j;
for(i=1;i<=L.length-1;i++)
{
for(j=1;j<=L.length-i;j++)
{
if(L.data[j]>L.data[j+1])
{
int temp;
temp=L.data[j];
L.data[j]=L.data[j+1];
L.data[j+1]=temp;
}
}
}
}
冒泡排序C
于 2024-09-08 17:06:03 首次发布