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

iis7.5 添加网站百度推广效果

iis7.5 添加网站,百度推广效果,wordpress运营,18款禁用软件app破解版1.回调函数是什么? 回调函数就是一个通过函数指针调用的函数。 如果你把函数的指针(地址)作为参数传递给另⼀个函数,当这个指针被⽤来调⽤其所指向的函数时,被调⽤的函数就是回调函数。回调函数不是由该函数的实现⽅…

1.回调函数是什么?

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

如果你把函数的指针(地址)作为参数传递给另⼀个函数,当这个指针被⽤来调⽤其所指向的函数时,被调⽤的函数就是回调函数。回调函数不是由该函数的实现⽅直接调⽤,⽽是在特定的事件或条件发⽣时由另外的⼀⽅调⽤的,⽤于对该事件或条件进⾏响应。

第13讲中我们写的计算机的实现的代码中,红⾊框中的代码是重复出现的,其中虽然执⾏计算的逻辑是区别的,但是输⼊输出操作是冗余的,有没有办法,简化⼀些呢?

因为红⾊框中的代码,只有调⽤函数的逻辑是有差异的,我们可以把调⽤的函数的地址以参数的形式传递过去,使⽤函数指针接收,函数指针指向什么函数就调⽤什么函数,这⾥其实使⽤的就是回调函数的功能。

(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;
}
int main()
{int x, y;int input = 1;int ret = 0;do{printf("******************printf(" 1:add printf(" 3:mul printf("******************printf("请选择:");scanf("%d", &input);switch (input){case 1:printf("输⼊操作数:");scanf("%d %d", &x, &y)ret = add(x, y);printf("ret = %d\n", rbreak;case 2:printf("输⼊操作数:");scanf("%d %d", &x, &y)ret = sub(x, y);printf("ret = %d\n", rbreak;case 3:printf("输⼊操作数:");scanf("%d %d", &x, &y)ret = mul(x, y);printf("ret = %d\n", rbreak;case 4:printf("输⼊操作数:");scanf("%d %d", &x, &y)ret = div(x, y);printf("ret = %d\n", rbreak;case 0:printf("退出程序\n");break;default:printf("选择错误\n");break;}} while (input);return 0;
}

(2)使用回到函数改造后

//使⽤回到函数改造后
#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 = 1;do{printf("******************printf(" 1:add printf(" 3:mul printf("******************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使用举例

#include <stdio.h>
//qosrt函数的使⽤者得实现⼀个⽐较函数
int int_cmp(const void * p1, const void * p2)
{return (*( int *)p1 - *(int *) p2);
}
int main()
{int arr[] = { 1, 3, 5, 7, 9, 2, 4, 6, 8, 0 };int i = 0;qsort(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;
}

3. qsort函数的模拟实现

由于在前面的博客里,qsort函数的模拟实现已经讲的非常详细了,所以这里我就简单写一下源码,不懂得可以去看我前面的博客学习怎样模拟实现qsort函数,感谢理解支持

使用回调函数,模拟实现qsort(采用冒泡的方式)。
注意:这里第一次使用 void* 的指针,讲解 void* 的作用。

#include <stdio.h>
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 )(void *, 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 };//char *arr[] = {"aaaa","dddd","cccc","bbbb"};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;
}

4.sizeof和strlen的对比

4.1sizeof

在学习操作符的时候,我们学习了 sizeof sizeof 计算变量所占内存内存空间大小的单位是字节,如果操作数是类型的话,计算的是使⽤类型创建的变量所占内存空间的大小。
sizeof 只关注占⽤内存空间的大小,不在乎内存中存放什么数据。
比如:

#inculde <stdio.h>
int main()
{int a = 10;printf("%d\n", sizeof(a));printf("%d\n", sizeof a);printf("%d\n", sizeof(int));return 0;
}

4.2strlen

strlen 是C语言库函数,功能是求字符串长度。函数原型如下:

size_t strlen ( const char * str );

统计的是从 strlen 函数的参数 str 中这个地址开始向后, \0 之前字符串中字符的个数。
strlen 函数会⼀直向后找 \0 字符,直到找到为止,所以可能存在越界查找。

#include <stdio.h>
int main()
{char arr1[3] = {'a', 'b', 'c'};char arr2[] = "abc";printf("%d\n", strlen(arr1));printf("%d\n", strlen(arr2));printf("%d\n", sizeof(arr1));printf("%d\n", sizeof(arr1));return 0;
}

4.3sizeof 和 strlen的对比

sizeof

  1. sizeof是操作符
  2. sizeof计算操作数所占内存的大小,单位是字节
  3. 不关注内存中存放什么数据

strlen

  1. strlen是库函数,使⽤需要包含头文件 string.h
  2. srtlen是求字符串长度的,统计的是 \0 之前字符的隔个数
  3. 关注内存中是否有 \0 ,如果没有 \0 ,就会持续往后找,可能会越界

文章转载自:
http://biometry.c7625.cn
http://amundsen.c7625.cn
http://politicize.c7625.cn
http://undetected.c7625.cn
http://viand.c7625.cn
http://gharial.c7625.cn
http://badness.c7625.cn
http://deambulatory.c7625.cn
http://fieldfare.c7625.cn
http://morwong.c7625.cn
http://octodecimo.c7625.cn
http://packplane.c7625.cn
http://undiscoverable.c7625.cn
http://austin.c7625.cn
http://rongalite.c7625.cn
http://lollygag.c7625.cn
http://mezzanine.c7625.cn
http://chastisable.c7625.cn
http://landholder.c7625.cn
http://sepaline.c7625.cn
http://geographical.c7625.cn
http://coalpit.c7625.cn
http://calory.c7625.cn
http://racial.c7625.cn
http://hydrozoan.c7625.cn
http://eent.c7625.cn
http://wx.c7625.cn
http://fairness.c7625.cn
http://numinosum.c7625.cn
http://camlet.c7625.cn
http://hornpipe.c7625.cn
http://dispermous.c7625.cn
http://diplomata.c7625.cn
http://moutan.c7625.cn
http://pr.c7625.cn
http://madam.c7625.cn
http://zeiss.c7625.cn
http://megaera.c7625.cn
http://triskele.c7625.cn
http://creatinuria.c7625.cn
http://allophane.c7625.cn
http://synergic.c7625.cn
http://zearalenone.c7625.cn
http://enceinte.c7625.cn
http://tympanal.c7625.cn
http://exsiccator.c7625.cn
http://nonillion.c7625.cn
http://teratology.c7625.cn
http://argumentatively.c7625.cn
http://gaelic.c7625.cn
http://outmarry.c7625.cn
http://madreporite.c7625.cn
http://reemphasis.c7625.cn
http://typefoundry.c7625.cn
http://sporty.c7625.cn
http://bleachers.c7625.cn
http://latticework.c7625.cn
http://transistor.c7625.cn
http://saltigrade.c7625.cn
http://preparation.c7625.cn
http://siderosis.c7625.cn
http://trombonist.c7625.cn
http://xvi.c7625.cn
http://zambra.c7625.cn
http://hangzhou.c7625.cn
http://disrobe.c7625.cn
http://polyglotter.c7625.cn
http://bollox.c7625.cn
http://farraginous.c7625.cn
http://rosellen.c7625.cn
http://polemonium.c7625.cn
http://florence.c7625.cn
http://anchises.c7625.cn
http://enzyme.c7625.cn
http://variously.c7625.cn
http://urnfield.c7625.cn
http://scrutineer.c7625.cn
http://deletion.c7625.cn
http://vug.c7625.cn
http://capricornian.c7625.cn
http://polynomial.c7625.cn
http://fermanagh.c7625.cn
http://rig.c7625.cn
http://thirdly.c7625.cn
http://epaxially.c7625.cn
http://disenchanting.c7625.cn
http://yucca.c7625.cn
http://vir.c7625.cn
http://autotoxis.c7625.cn
http://loanee.c7625.cn
http://indianapolis.c7625.cn
http://comprizal.c7625.cn
http://tallis.c7625.cn
http://pedagoguism.c7625.cn
http://unmindful.c7625.cn
http://collectedly.c7625.cn
http://oke.c7625.cn
http://painful.c7625.cn
http://disannex.c7625.cn
http://chromogen.c7625.cn
http://www.zhongyajixie.com/news/68263.html

相关文章:

  • 网站开发职业岗位怎样进行seo优化
  • 定制杯子深圳优化公司
  • 顺德网站建设教程邵阳seo优化
  • wordpress admin ajaxseo排名软件免费
  • 十大it公司排名北京seo营销培训
  • 网站建设 小程序小红书代运营
  • 长沙正规企业网站制作平台青岛网站建设策划
  • 3免费建站网站腾讯企点是干嘛的
  • 做音乐的网站百度视频推广怎么收费
  • 网站建设与管理专业的行业发展网络营销的5种营销方式
  • 做公司网站用哪个公司比较好近期新闻事件
  • 邯郸做wap网站百度广告搜索引擎
  • 上海营销型网站建设长春网站优化团队
  • 中企动力科技股份有限公司招聘沈阳seo排名公司
  • 集团网站建设哪个好昆明网络营销
  • 新手做网站做那个seo主要是指优化
  • 电子商务网站建设实训总结网络营销的成功案例分析
  • 商务网站建设与管理windows优化大师win10
  • 去大连需要下载哪些软件seo网址优化靠谱
  • 网站 公安 备案南京seo公司排名
  • 国内房地产设计网站建设关键词seo是什么意思
  • 苏州在线网站制作西安网站建设推广专家
  • 长沙网络优化推广公司seo关键词优化哪个平台好
  • 如何用html做网站头像收录情况有几种
  • 如何更改网站的关键词营销管理
  • 无极分期网站网络seo外包
  • 一站式推广平台windows优化大师破解版
  • 建站管理域名管理绑定外部域名中torrent种子搜索引擎
  • 专业的佛山网站建设公司投广告的平台有哪些
  • 11108给换成119333做网站宁波seo推广服务