#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h> void swap(const char**, const char**);
void bubble_sort(const char**, int); int main(void)
{
char str_1[] = {
52,5,8,96,78,23,12,4,9,2
};
int str_len = sizeof(str_1); const char **pStr_1 = malloc(sizeof(char*)*str_len);
int i = 0;
for (; i < str_len; ++i)
{
*(pStr_1+i) = str_1+i;
}
bubble_sort(pStr_1, str_len);
i = 0;
for (; i < str_len; ++i)
{
printf("%d\n", *(*(pStr_1+i)));
}
} void swap(const char **p1, const char **p2)
{
const char *pT = *p1;
*p1 = *p2;
*p2 = pT;
} void bubble_sort(const char **arr, int len)
{
int i = 0;
int j = 0;
for (; i < len; ++i)
{ j = len - 1;
for (; j > i; --j)
{
if( *(*(arr+j)) < *(*(arr+(j-1))) )
{
swap(arr+j, arr+(j-1));
}
}
}
}

  

[C][代码实例]冒泡排序的更多相关文章

  1. MATLAB的PLOT函数线型设置及横坐标为字符串的代码实例

    2.横坐标为字符串的代码实例 cell={‘PLS’,’SVM’,’RF’,’NNET’,’NB’,’PLR’,’C5.0′,’PDA’,’KNN’,’GLM’,’BCT’};%分类方法yData=[ ...

  2. web service上传参数代码实例

    web service上传参数代码实例 这次做的项目用到webservice比较多,最开始在网上看的参考dome,发现都不行,后来发现安卓4.0以后有很大的不同,在做传参时,有些东西需要注意: 第一, ...

  3. (转)combogrid的代码实例

    EasyUI中combogrid的代码实例 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &q ...

  4. PHP生成迅雷、快车、旋风等软件的下载链接代码实例

    PHP生成迅雷.快车.旋风等软件的下载链接代码实例 <?php function Download() { $urlodd=explode('//',$_POST["url" ...

  5. Scala 深入浅出实战经典 第45讲: scala中context bounds代码实例

    王家林亲授<DT大数据梦工厂>大数据实战视频 Scala 深入浅出实战经典(1-64讲)完整视频.PPT.代码下载:百度云盘:http://pan.baidu.com/s/1c0noOt6 ...

  6. 关于JAVA中事件分发和监听机制实现的代码实例-绝对原创实用

    http://blog.csdn.net/5iasp/article/details/37054171 文章标题:关于JAVA中事件分发和监听机制实现的代码实例 文章地址: http://blog.c ...

  7. input文本框实现宽度自适应代码实例

    代码实例如下: <!DOCTYPE html> <html><head><meta charset="utf-8"><meta ...

  8. jQuery实现的鼠标滑过切换图片代码实例

    jQuery实现的鼠标滑过切换图片代码实例:有时候网页需要这样的简单效果,那就是当鼠标滑过默认图片的时候,能够实现图片的切换,可能在实际应用中,往往没有这么简单,不过大家可以自行扩展一下,下面简单介绍 ...

  9. input文本框实现宽度自适应代码实例,input文本框

    本章节介绍一下如何让一个文本框的宽度能够随着文本框中的内容的宽度增长而增长,也就是能够实现宽度自适应效果. 代码实例如下: <!DOCTYPE html> <html> < ...

随机推荐

  1. vue cli 解决跨域 线上 nginx 反向代理配置

    前后分离 axios 接 api 跨域问题如图: 解决办法: 1. npm start 本地开发环境解决: 在webpack配置文件 /config/index.js 里找到 proxyTable 开 ...

  2. C++ WString与String互相转换

    std::wstring StringToWString(const std::string& str) { , str.c_str(), -, NULL, ); wchar_t *wide ...

  3. Groovy 类名称赋值为变量使用(newInstance & new)

    类创建实例一般方式 http://groovy-lang.org/objectorientation.html#_class class Person { String name Integer ag ...

  4. 第26月第30天 srt

    1. ffmpeg -i 0.mp4 -vf subtitles=0.srt 1.mp4 https://jingyan.baidu.com/article/c45ad29c73cef2051653e ...

  5. 第23月第24天 git命令 .git-credentials git rm --cached git stash clear

    在git push的时候,有时候我们会想办法撤销git commit的内容 1.找到之前提交的git commit的id git log 找到想要撤销的id 2.git reset –hard id ...

  6. netty的解码器和粘包拆包

    Tcp是一个流的协议,一个完整的包可能会被Tcp拆成多个包进行发送,也可能把一个小的包封装成一个大的数据包发送,这就是所谓的粘包和拆包问题 粘包.拆包出现的原因: 在流传输中出现,UDP不会出现粘包, ...

  7. 【mmall】mybatis三剑客

    mybatis-generator mybatis-plugin Mybatis Plugin插件安装破解及使用:http://blog.csdn.net/u011410529/article/det ...

  8. tcp黏包

    转载https://www.cnblogs.com/wade-luffy/p/6165671.html 无论是服务端还是客户端,当我们读取或者发送消息的时候,都需要考虑TCP底层的粘包/拆包机制. 回 ...

  9. tomcat源码之connector配置

    连接 acceptor /** * Acceptor thread count. */protected int acceptorThreadCount = 0; 处理线程 private int m ...

  10. J - Joyful HDU - 5245 (概率)

    题目链接: J - Joyful  HDU - 5245 题目大意:给你一个n*m的矩阵,然后你有k次涂色机会,然后每一次可以选定当前矩阵的一个子矩阵染色,问你这k次用完之后颜色个数的期望. 具体思路 ...