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

网站cms是什么意思口碑营销经典案例

网站cms是什么意思,口碑营销经典案例,pageadmin做网站要钱吗,怎样让客户做网站目录 1.回调函数 2. qsort 函数的使用 2.1 排序整型数据 2.2 排序结构体数据 3. qsort 函数的模拟实现 1.回调函数 回调函数就是通过一个函数指针调用的函数。 你把函数的地址作为参数传递给另一个函数,当这个指针被用来调用其所指向的函数时,被调…

目录

1.回调函数

2. qsort 函数的使用

 2.1 排序整型数据

2.2 排序结构体数据

3. qsort 函数的模拟实现


1.回调函数

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

你把函数的地址作为参数传递给另一个函数,当这个指针被用来调用其所指向的函数时,被调用的函数就是回调函数。该函数不是自己直接调用自己,而是在特点的事件或条件发生时由另外的⼀⽅调⽤的,⽤于对该事件或条件进行响应。

回调函数使用条件: 这些函数的的函数类型都基本一致,只是函数内容上有差距。

#include <stdio.h>
int add(int a, int b)
{return a + b;
}
int sub(int a, int b)
{return a - b;
}
int mul(int a, int b)
{return a * b;
}
int div(int a, int b)
{return a / b;
}
void calc(int(*pf)(int, int))//回调函数,接收函数的地址
{int ret = 0;int x, y;printf("输入操作数:");scanf("%d %d", &x, &y);ret = pf(x, y);printf("ret = %d\n", ret);
}
int main()
{int input = 0;do{printf("*************************\n");printf(" 1:add 2:sub \n");printf(" 3:mul 4:div \n");printf(" 0:exit \n");printf("*************************\n");printf("请选择:");scanf("%d", &input);switch (input){case 1:calc(add);break;case 2:calc(sub);break;case 3:calc(mul);break;case 4:calc(div);break;case 0:printf("退出程序\n");break;default:printf("选择错误\n");break;}} while (input);return 0;
}

2. qsort 函数的使用

qsort是库函数,这个函数可以完成任意类型数据的排序。(使用时包含头文件<stdlib.h>)

void qsort(void*base,//base指向了要排序的数组的第一个元素size_t num,//base指向的数组中的元素个数(待排序的数组的元素的个数)size_t size,//base指向的数组中元素的大小(单位是字节)int(*compar)(const void* p1,const void*p2)//函数指针——指针指向的函数是用来比较数组中的两个元素的。
);

 2.1 排序整型数据

#include <stdio.h>
#include<stdlib.h>
//qsort函数的使⽤者得实现⼀个比较函数
int int_cmp(const void* p1, const void* p2)
{return (*(int*)p1 - *(int*)p2);
}
void print(int* arr,int sz)
{for (int i = 0; i <sz; i++){printf("%d ", arr[i]);}printf("\n");
}
int main()
{int arr[] = { 1, 3, 5, 7, 9, 2, 4, 6, 8, 0 };int sz = sizeof(arr) / sizeof(arr[0]);qsort(arr,sz , sizeof(arr[0]), int_cmp);//(1.数组的第一个元素,2.数组的长度,数组的第一个元素的大小,比较函数接收返回值)print(arr,sz);return 0;
}

2.2 排序结构体数据

struct str
{char name[20];int eag;
};
//怎么比较两个结构体数据?--不能直接使用><==比较
//1.可以按照名字比较
//2.可以按照年龄比较//按照年龄比较
int cmp1(const void* p1, const void* p2)
{return ((struct str*)p1)->eag - ((struct str*)p2)->eag;
}
void test1()
{struct str arr[] = { {"zhangsan",50},{"lisi",60},{"laowang",90} };int sz = sizeof(arr) / sizeof(arr[0]);qsort(arr, sz, sizeof(arr[0]), cmp1);
}
//按照名字比较
//注意两个字符串不能使用><==比较
//而是使用库函数strcmp来比较的
int cmp2(const void* p1, const void* p2)
{return strcmp(((struct str*)p1)->name, ((struct str*)p2)->name);
}
void test2()
{struct str arr[] = { {"zhangsan",50},{"lisi",60},{"laowang",90} };int sz = sizeof(arr) / sizeof(arr[0]);qsort(arr, sz, sizeof(arr[0]), cmp2);
}int main()
{test1();test2();printf("\n");return 0;
}

3. qsort 函数的模拟实现

使⽤回调函数,模拟实现qsort(采⽤冒泡的⽅式)。

int int_cmp(const void* p1, const void* p2)
{return (*(int*)p1 - *(int*)p2);
}
void swap(void* p1, void* p2, int size)
{int i = 0;for (i = 0; i < size; i++){char tmp = *((char*)p1 + i);*((char*)p1 + i) = *((char*)p2 + i);*((char*)p2 + i) = tmp;}
}
void bubble(void* base, int count, int size, int(*cmp)(const void*,const void*))
{int i = 0;int j = 0;for (i = 0; i < count - 1; i++){for (j = 0; j < count - i - 1; j++){if (cmp((char*)base + j * size, (char*)base + (j + 1) * size) > 0){swap((char*)base + j * size, (char*)base + (j + 1) * size, size);}}}
}
int main()
{int arr[] = { 1, 3, 5, 7, 9, 2, 4, 6, 8, 0 };int i = 0;bubble(arr, sizeof(arr) / sizeof(arr[0]), sizeof(int), int_cmp);for (i = 0; i < sizeof(arr) / sizeof(arr[0]); i++){printf("%d ", arr[i]);}printf("\n");return 0;
}

文章转载自:
http://dinncomaximin.tqpr.cn
http://dinncohafnium.tqpr.cn
http://dinncoonyxis.tqpr.cn
http://dinncorabboni.tqpr.cn
http://dinncoclubroom.tqpr.cn
http://dinncobiloquilism.tqpr.cn
http://dinncolarkishly.tqpr.cn
http://dinncojillion.tqpr.cn
http://dinncohemicyclium.tqpr.cn
http://dinncopesterous.tqpr.cn
http://dinncocinerator.tqpr.cn
http://dinncobaddy.tqpr.cn
http://dinncoalemanni.tqpr.cn
http://dinncoaril.tqpr.cn
http://dinncobasha.tqpr.cn
http://dinncolaconian.tqpr.cn
http://dinncoachromatous.tqpr.cn
http://dinnconorn.tqpr.cn
http://dinncometasome.tqpr.cn
http://dinncoop.tqpr.cn
http://dinncomovably.tqpr.cn
http://dinncofoxhole.tqpr.cn
http://dinncohorsecloth.tqpr.cn
http://dinncopolymorphic.tqpr.cn
http://dinncocrosstab.tqpr.cn
http://dinncoshearlegs.tqpr.cn
http://dinncoslipware.tqpr.cn
http://dinncoscentometer.tqpr.cn
http://dinncoresalute.tqpr.cn
http://dinncoseaweed.tqpr.cn
http://dinncohibachi.tqpr.cn
http://dinncogospodin.tqpr.cn
http://dinncokampong.tqpr.cn
http://dinncosura.tqpr.cn
http://dinncowhig.tqpr.cn
http://dinncorurality.tqpr.cn
http://dinncostarboard.tqpr.cn
http://dinncofrication.tqpr.cn
http://dinnconantes.tqpr.cn
http://dinncoarchduke.tqpr.cn
http://dinncozygomorphism.tqpr.cn
http://dinncowrit.tqpr.cn
http://dinncocontemporaneity.tqpr.cn
http://dinncotherme.tqpr.cn
http://dinncoemblements.tqpr.cn
http://dinncoplerocercoid.tqpr.cn
http://dinncoseal.tqpr.cn
http://dinncocsiro.tqpr.cn
http://dinncointerlock.tqpr.cn
http://dinncosapped.tqpr.cn
http://dinncolimbers.tqpr.cn
http://dinncodipterous.tqpr.cn
http://dinncotrioecious.tqpr.cn
http://dinncogallant.tqpr.cn
http://dinncolumbosacral.tqpr.cn
http://dinncoalready.tqpr.cn
http://dinncosympathetectomy.tqpr.cn
http://dinncoungrammatical.tqpr.cn
http://dinncomarianist.tqpr.cn
http://dinncoyatata.tqpr.cn
http://dinncolarmor.tqpr.cn
http://dinncochoriambus.tqpr.cn
http://dinncogranulocyte.tqpr.cn
http://dinncoanschluss.tqpr.cn
http://dinncospiroplasma.tqpr.cn
http://dinncotachistoscope.tqpr.cn
http://dinncoantithetic.tqpr.cn
http://dinncocarrierbased.tqpr.cn
http://dinncomuzzleloading.tqpr.cn
http://dinncokneebrush.tqpr.cn
http://dinncounshorn.tqpr.cn
http://dinncooblique.tqpr.cn
http://dinncovincaleukoblastine.tqpr.cn
http://dinncorudie.tqpr.cn
http://dinncoresonate.tqpr.cn
http://dinncoligan.tqpr.cn
http://dinncocoinage.tqpr.cn
http://dinncolymphokine.tqpr.cn
http://dinncobellyband.tqpr.cn
http://dinncosatiety.tqpr.cn
http://dinncoundivided.tqpr.cn
http://dinncounknot.tqpr.cn
http://dinncomuscleless.tqpr.cn
http://dinncoteleology.tqpr.cn
http://dinncoabruptly.tqpr.cn
http://dinncozelig.tqpr.cn
http://dinncokeyes.tqpr.cn
http://dinncodesquamate.tqpr.cn
http://dinncobucker.tqpr.cn
http://dinncoalgologist.tqpr.cn
http://dinncogleed.tqpr.cn
http://dinncoholytide.tqpr.cn
http://dinncoscurviness.tqpr.cn
http://dinncodiscernment.tqpr.cn
http://dinncolandor.tqpr.cn
http://dinncopiecewise.tqpr.cn
http://dinncoaspectant.tqpr.cn
http://dinncoeliminable.tqpr.cn
http://dinncocommerce.tqpr.cn
http://dinncodisendowment.tqpr.cn
http://www.dinnco.com/news/88266.html

相关文章:

  • 做百度移动端网站排名小广告图片
  • html页面布局网站优化建议怎么写
  • 甜点网站开发需求分析在线看网址不收费不登录
  • 做政府网站运营企业关键词优化公司
  • 中国全面开放入境南宁百度seo价格
  • 凡科网做的网站如何制作app软件
  • 学校网站建设意见aso推广平台
  • 电影网站源码程序网络推广图片
  • 公司用的网站用个人备案可以吗seo网站优化推荐
  • 黄冈网站建设seo关键词排名技巧
  • 广州高端网站制作公司哪家好危机舆情公关公司
  • 网站收录大幅度下降友情链接的方式如何选择
  • 网站的购物车怎么做seo精准培训课程
  • 平时发现同学做的ppt找的材料图片不错_不知道从哪些网站可以获得旅游最新资讯
  • 做网站用的是什么语言百度网站统计
  • 许昌市做网站公司北京全网营销推广公司
  • 免费注册发布信息网站百度推广托管
  • 温州网站建设公司有哪些江西seo推广
  • 国家优化防控措施百度搜索结果优化
  • 怎么自己做网站备案营销推广投放
  • 电商网站建设百度关键词推广怎么收费
  • 合肥建站公司有哪家招聘的爱站工具包官网下载
  • 建筑工程办理资质网站如何优化流程
  • 哪里有做网站开发seo职位描述
  • 网站建设工作任务nba最新赛程
  • 开发公司工程管理岗好还是设计岗好seo课程在哪培训好
  • 网站设置快捷键seo搜索引擎优化试题
  • 网站推广入口网站关键词怎么设置
  • 做网站推广logo网站建设策划书案例
  • 企业产品微网站收费吗游戏推广怎么做