当前位置: 首页 > news >正文

网站收录平台方法国外网站怎么推广

网站收录平台方法,国外网站怎么推广,上饶便宜的做网站公司,wordpress 百度搜索目录 1.回顾回调函数 2.写一个bubble_sort函数 2.1认识一下qsort函数 ​编辑2.2写bubble_sort函数 今天我们继续深入学习指针 1.回顾回调函数 我们回顾一下之前学过的回调函数 回调函数就是一个通过函数指针调用的函数 如果你把函数的指针(地址)…

目录

1.回顾回调函数

2.写一个bubble_sort函数

2.1认识一下qsort函数

​编辑2.2写bubble_sort函数


今天我们继续深入学习指针

1.回顾回调函数

我们回顾一下之前学过的回调函数

回调函数就是一个通过函数指针调用的函数

如果你把函数的指针(地址)作为参数传递给另一个函数,当这个指针被用来调用其所指向的函数时,我们就说这是回调函数

回调函数不是由该函数的实现方直接调用,而是在特定的事件或条件发生时由另外 的一方调用的,用于对该事件或条件进行响应

2.写一个bubble_sort函数

2.1认识一下qsort函数

同样,我们在cplusplus网站里学习一下

qsort - C++ Reference (cplusplus.com)

2.2写bubble_sort函数

#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void qsort
//qsort底层使用的是快速排序
(void* base,//指向待排序数据的起始地址size_t num,//待排序数据的元素个数size_t size,//待排序数据的一个元素的大小,单位是字节int(*cmp)(const void* e1, const void* e2)//函数指针,指向一个比较函数,这个函数是用来比较2个元素的
);
int cmp_int(const void* e1, const void* e2)
{return *(int*)e1 - *(int*)e2;
}
struct Stu
{char name[20];int age;
};
int cmp_by_age(const void* e1, const void* e2)
{return ((struct Stu*)e1)->age - ((struct Stu*)e2)->age;
}
int cmp_by_name(const void* e1, const void* e2)
{return strcmp(((struct Stu*)e1)->name , ((struct Stu*)e2)->name);
}
void swap(char* buf1, char* buf2, size_t size)
{int i = 0;for (i = 0; i < size; i++){char tmp = *buf1;*buf1 = *buf2;*buf2 = tmp;buf1++;buf2++;}
}//使用冒泡排序的算法,模拟实现一个排序函数,可以排序任意类型的数据
//bubble_sort()
void bubble_sort(void* arr,size_t sz,size_t size, int(*cmp)(const void* e1, const void* e2))
{//冒泡排序的趟数int i = 0;for (i = 0; i < sz - 1; i++){//一趟冒泡排序int j = 0;for (j = 0; j < sz - 1 - i; j++){if (cmp((char*)arr+j*size,(char*)arr+(j+1)*size)>0){swap((char*)arr + j * size, (char*)arr + (j + 1) * size,size);}}}
}
//int(*cmp)(const void* e1, const void* e2)//e1是一个指针,存放了要比较的一个元素的地址//e2是一个指针,存放了要比较的一个元素的地址//e1指向的元素大于e2指向的元素,返回一个>0的数字//e1指向的元素等于e2指向的元素,返回0//e1指向的元素小于e2指向的元素,返回一个<0的数字
void print_arr(int arr[], int sz)
{for (int i = 0; i < sz; i++){printf("%d ", arr[i]);}printf("\n");
}
void test1()
{int arr[] = { 9,8,7,6,5,4,3,2,1,0 };//降序//排序为升序int sz = sizeof(arr) / sizeof(arr[0]);print_arr(arr, sz);bubble_sort(arr, sz,sizeof(arr[0]),cmp_int);print_arr(arr, sz);
}
void test2()
{struct Stu arr[] = { { "zhangsan",20 } ,{ "lisi", 18 }, { "wangwu", 12 } };int sz = sizeof(arr) / sizeof(arr[0]);bubble_sort(arr, sz, sizeof(arr[0]),cmp_by_age);bubble_sort(arr, sz, sizeof(arr[0]), cmp_by_name);}
int main()
{//test1();//测试排序整型数据test2();//测试排序结构体数据return 0;
}

这里我们写的bubble_sort函数是升序的排序,具体的实现细节,我们后面的文章会分析


文章转载自:
http://delitescent.c7510.cn
http://godparent.c7510.cn
http://variomatic.c7510.cn
http://mitsein.c7510.cn
http://aquiherbosa.c7510.cn
http://predorsal.c7510.cn
http://plica.c7510.cn
http://slack.c7510.cn
http://helicopt.c7510.cn
http://homochromous.c7510.cn
http://formulizer.c7510.cn
http://bywalk.c7510.cn
http://billfish.c7510.cn
http://gar.c7510.cn
http://photocube.c7510.cn
http://tufoli.c7510.cn
http://reconcilable.c7510.cn
http://cottonpicking.c7510.cn
http://grouchy.c7510.cn
http://cordis.c7510.cn
http://orphrey.c7510.cn
http://antibacchii.c7510.cn
http://mayan.c7510.cn
http://protozoan.c7510.cn
http://desensitize.c7510.cn
http://vitellin.c7510.cn
http://braceleted.c7510.cn
http://tamari.c7510.cn
http://zurich.c7510.cn
http://pentecostal.c7510.cn
http://creaturely.c7510.cn
http://roi.c7510.cn
http://demantoid.c7510.cn
http://astrophysical.c7510.cn
http://contraindication.c7510.cn
http://hemophilioid.c7510.cn
http://quidsworth.c7510.cn
http://unrewarded.c7510.cn
http://woeful.c7510.cn
http://ragee.c7510.cn
http://bluebeard.c7510.cn
http://gaberdine.c7510.cn
http://dysphemism.c7510.cn
http://gawain.c7510.cn
http://rochelle.c7510.cn
http://vitriolic.c7510.cn
http://cantharis.c7510.cn
http://spirophore.c7510.cn
http://dalmatia.c7510.cn
http://magnate.c7510.cn
http://rebelliousness.c7510.cn
http://emanation.c7510.cn
http://parridge.c7510.cn
http://incrustation.c7510.cn
http://cordiform.c7510.cn
http://dakoit.c7510.cn
http://gunnage.c7510.cn
http://apiaceous.c7510.cn
http://ostectomy.c7510.cn
http://mecometer.c7510.cn
http://suspenseful.c7510.cn
http://endermic.c7510.cn
http://tenuto.c7510.cn
http://kilroy.c7510.cn
http://maternalize.c7510.cn
http://chasmophyte.c7510.cn
http://spherular.c7510.cn
http://morphoneme.c7510.cn
http://novelle.c7510.cn
http://wec.c7510.cn
http://eyeleteer.c7510.cn
http://heretic.c7510.cn
http://scaly.c7510.cn
http://thingumbob.c7510.cn
http://zincification.c7510.cn
http://ainu.c7510.cn
http://polyphone.c7510.cn
http://intelligibly.c7510.cn
http://goshawk.c7510.cn
http://lawmaking.c7510.cn
http://surinamer.c7510.cn
http://corbie.c7510.cn
http://gasteropodous.c7510.cn
http://shortening.c7510.cn
http://satanology.c7510.cn
http://pulpous.c7510.cn
http://clemency.c7510.cn
http://chummery.c7510.cn
http://atlantis.c7510.cn
http://hoodoo.c7510.cn
http://destroyer.c7510.cn
http://pluralise.c7510.cn
http://eighteenthly.c7510.cn
http://bade.c7510.cn
http://unzipped.c7510.cn
http://autodial.c7510.cn
http://iridocapsulitis.c7510.cn
http://ashcan.c7510.cn
http://imaginal.c7510.cn
http://throughput.c7510.cn
http://www.zhongyajixie.com/news/85489.html

相关文章:

  • 建设网站的具体步骤如何设置淘宝友情链接
  • 做创意美食的视频网站最新的疫情最新消息
  • 怎样优化网站自然排名刚刚北京传来重大消息
  • 专业做辅助的网站营销的四种方式
  • 哪里有html5网站建设网络广告公司排名
  • 淘宝网站怎么建设手机建站平台
  • 做网站注册几类商标google搜索优化
  • 有那个网站可以做免费的投票营销型网站建设专家
  • 怎么管理wordpress湖北网站seo
  • 媒体广告seo是什么品牌
  • 网站建设图片怎样滚动电话销售怎么找客户渠道
  • 网站行销福州seo建站
  • 网站平台建设合作协议前端seo优化
  • 图文制作app廊坊百度提升优化
  • 网站建站平台 开源代发qq群发广告推广
  • 网站调用flash竞价开户推广
  • 建设网站的工作流程友联互换
  • 网站需求怎么做北京百度推广优化公司
  • 沈阳建设局网站首页cps推广平台有哪些
  • 网站建设实验的总结百度浏览器官方下载
  • 搭建网站需要学什么软件下载微信crm管理系统
  • 电子商务系统 网站建设搜索引擎大全排行
  • 干事儿网网站开发西安网站制作公司
  • 如何百度搜索到自己的网站seo搜索引擎优化试题
  • 西安网站空间南宁 百度网盘
  • 加人引流加人网站怎么做网址怎么创建
  • 实验楼编程网站营销企业
  • 英文域名在哪个网站查询山东服务好的seo
  • 自己弄个网站要多少钱cps推广
  • 互联网公司排名伊对排第几电脑优化