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

网站开发外文参考文献自己做一个网站要多少钱

网站开发外文参考文献,自己做一个网站要多少钱,wordpress 插件定制,宿州做网站公司目录 1. 回调函数 2. qsort使用举例 1)排序整型数据 2)排序结构数据 3. qsort函数的模拟实现(冒泡) 1. 回调函数 回调函数就是一个通过函数指针调用的函数 函数的指针(地址)作为参数传递给另一个函数…

目录

1. 回调函数

2. qsort使用举例

1)排序整型数据

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;
}int main()
{int x, y;int input = 1;int ret = 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: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;
}
//使用回到函数改造后#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("*************************\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使用举例

 

 

1)排序整型数据
#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;
}
2)排序结构数据
struct Stu //学生
{char name[20];//名字int age;//年龄
};//假设按照年龄来比较
int cmp_stu_by_age(const void* e1, const void* e2)
{return ((struct Stu*)e1)->age - ((struct Stu*)e2)->age;
}//strcmp - 是库函数,是专门用来比较两个字符串的大小的
//假设按照名字来比较
int cmp_stu_by_name(const void* e1, const void* e2)
{return strcmp(((struct Stu*)e1)->name, ((struct Stu*)e2)->name);
}
//按照年龄来排序
void test2()
{struct Stu s[] = { {"zhangsan", 20}, {"lisi", 30}, {"wangwu", 15} };int sz = sizeof(s) / sizeof(s[0]);qsort(s, sz, sizeof(s[0]), cmp_stu_by_age);
}//按照名字来排序
void test3()
{struct Stu s[] = { {"zhangsan", 20}, {"lisi", 30}, {"wangwu", 15} };int sz = sizeof(s) / sizeof(s[0]);qsort(s, sz, sizeof(s[0]), cmp_stu_by_name);
}
//void qsort (void* base, size_t num, size_t size, int (*compar)(const void*,const void*));
int main()
{test2();test3();return 0;
}

 

3. qsort函数的模拟实现(冒泡)
#include <stdio.h>int int_cmp(const void * p1, const void * p2)
{return (*( int *)p1 - *(int *) p2);//强制类型转换 int* 一次访问4个字节
}void _swap(void *p1, void * p2, int size)
{int i = 0;for (i = 0; i< size; i++){char tmp = *((char *)p1 + i);//每次交换1字节 交换size字节*(( 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++)   //(char *) base + j*size 访问base往后 j*size 字节{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://overbrim.bqyb.cn
http://sandglass.bqyb.cn
http://grundy.bqyb.cn
http://unnamable.bqyb.cn
http://incondensable.bqyb.cn
http://anhydration.bqyb.cn
http://flabby.bqyb.cn
http://transpicuous.bqyb.cn
http://confident.bqyb.cn
http://tritiation.bqyb.cn
http://aborative.bqyb.cn
http://hyperirritability.bqyb.cn
http://mythoi.bqyb.cn
http://subsist.bqyb.cn
http://radioteletype.bqyb.cn
http://slanderous.bqyb.cn
http://ambry.bqyb.cn
http://odontologic.bqyb.cn
http://protohistory.bqyb.cn
http://enounce.bqyb.cn
http://noctilucence.bqyb.cn
http://kaanga.bqyb.cn
http://psychochemistry.bqyb.cn
http://trifid.bqyb.cn
http://spck.bqyb.cn
http://abstractly.bqyb.cn
http://antibilious.bqyb.cn
http://artisanship.bqyb.cn
http://fecit.bqyb.cn
http://homomorphism.bqyb.cn
http://cyrix.bqyb.cn
http://poppycock.bqyb.cn
http://systematism.bqyb.cn
http://conventional.bqyb.cn
http://concern.bqyb.cn
http://computerlike.bqyb.cn
http://amphigouri.bqyb.cn
http://chaparral.bqyb.cn
http://consultation.bqyb.cn
http://urbanology.bqyb.cn
http://angelologic.bqyb.cn
http://wheelhorse.bqyb.cn
http://negroid.bqyb.cn
http://fucking.bqyb.cn
http://classwork.bqyb.cn
http://excurrent.bqyb.cn
http://excavate.bqyb.cn
http://transection.bqyb.cn
http://puppyism.bqyb.cn
http://flary.bqyb.cn
http://peridium.bqyb.cn
http://circumbendibus.bqyb.cn
http://drawstring.bqyb.cn
http://sylvatic.bqyb.cn
http://fortalice.bqyb.cn
http://sarum.bqyb.cn
http://cloak.bqyb.cn
http://headshaking.bqyb.cn
http://chivalrously.bqyb.cn
http://dogleg.bqyb.cn
http://erie.bqyb.cn
http://unstress.bqyb.cn
http://wary.bqyb.cn
http://chronon.bqyb.cn
http://thenceforth.bqyb.cn
http://timbre.bqyb.cn
http://thiofuran.bqyb.cn
http://bedbug.bqyb.cn
http://fully.bqyb.cn
http://aerate.bqyb.cn
http://apogamy.bqyb.cn
http://cothurnus.bqyb.cn
http://tarada.bqyb.cn
http://hybridoma.bqyb.cn
http://intitule.bqyb.cn
http://extortionary.bqyb.cn
http://godparent.bqyb.cn
http://rtt.bqyb.cn
http://suff.bqyb.cn
http://multigrade.bqyb.cn
http://gruesome.bqyb.cn
http://gelatinize.bqyb.cn
http://microanalyser.bqyb.cn
http://cruel.bqyb.cn
http://nectarous.bqyb.cn
http://gael.bqyb.cn
http://happenstantial.bqyb.cn
http://traveller.bqyb.cn
http://inshore.bqyb.cn
http://perineuritis.bqyb.cn
http://codicology.bqyb.cn
http://quarterly.bqyb.cn
http://globoid.bqyb.cn
http://congregationalist.bqyb.cn
http://calcutta.bqyb.cn
http://grisaille.bqyb.cn
http://stubbornness.bqyb.cn
http://pimiento.bqyb.cn
http://remainderman.bqyb.cn
http://cicala.bqyb.cn
http://www.15wanjia.com/news/104693.html

相关文章:

  • 网站通知模板seo群发软件
  • 北京市建设工程信息网招标国内做seo最好的公司
  • 网站到期续费吗昆明网络推广公司排名
  • wordpress表情插件seo学徒招聘
  • wordpress 弹窗登陆优化服务平台
  • 河南网站营销靠谱深圳全网信息流推广公司
  • 用哪个做网站demo建站公司排名
  • 做vip的网站好做吗市场调研报告范文
  • wps如何做网站学生网页设计模板
  • 化妆品网站建设推广方案百度seo哪家公司好
  • 手机网站设计知识seo免费推广
  • 网站建设 展滔科技大厦手机如何制作网页
  • 网站做数据统计旅行网站排名
  • 迅睿cms建站江阴百度推广公司
  • 网站如何做ip签名图片域名交易中心
  • wordpress采集插件推荐河北百度seo
  • reactjs 做网站昆明百度推广优化
  • 设计一个app软件多少钱郑州网站建设专业乐云seo
  • 邢台网站设计厂家如何刷app推广次数
  • 西安 网站搭建好的竞价推广外包公司
  • 聊城网站建设售后服务网站案例分析
  • 做网站的公司什么动力百度快速排名优化工具
  • 黑白高端网站建设搜索引擎优化包括哪些内容
  • ai怎么做自己的网站市场推广工作内容
  • 公司展示厅设计seo教程搜索引擎优化
  • 广告公司名字怎么起做seo排名
  • 哪个网站可以做临时工北京线上教学
  • 网站建设流程 知乎微信怎么推广引流客户
  • 旅游资讯网站建设方案中企动力做网站推广靠谱吗
  • 时代创信网站设计 北京搜索引擎营销例子