2 Star 2 Fork 0

SmithGoll/c语言学习

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
sort.c 608 Bytes
一键复制 编辑 原始数据 按行查看 历史
SmithGoll 提交于 2022-06-22 04:08 . c语言上的一些功能实现
#include<stdio.h>
void sort(int iArray[],int count)
{
int pos,tmp;
for(int i = 0;i < count;i++)
{
pos = i;
while(pos && iArray[pos] < iArray[pos - 1])
{
tmp = iArray[pos];
iArray[pos] = iArray[pos - 1];
iArray[pos - 1] = tmp;
pos--;
}
}
return;
}
int main()
{
int array[] = {122,545,49,378,73,481,34,87,384,348,454,48,648};
printf("The count of array:%lu\n",sizeof(array)/sizeof(int));
for(int k = 0;;k++)
{
for(int j = 0;j < sizeof(array)/sizeof(int);j++)
printf("%d ",array[j]);
putchar('\n');
if(k)
break;
sort(array,sizeof(array)/sizeof(int));
}
return 0;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/smithgoll/c-language-learning.git
git@gitee.com:smithgoll/c-language-learning.git
smithgoll
c-language-learning
c语言学习
master

搜索帮助