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

南京市高淳县建设厅网站ppt设计理念

南京市高淳县建设厅网站,ppt设计理念,怎么查网站的所有权,python做网站源码目录 叁、函数与字符串 肆、函数与指针 4.1 指针作为函数参数 4.2 函数返回指针 4.3 函数指针与函数指针数组 4.4 结构体指针 ​​​​​​​​​​​​​​小樽C 多章⑧ (壹) 指针变量https://blog.csdn.net/weixin_44775255/article/details/129031168 小樽C 多章⑧ …目录 叁、函数与字符串 肆、函数与指针 4.1 指针作为函数参数 4.2 函数返回指针 4.3 函数指针与函数指针数组 4.4 结构体指针  ​​​​​​​​​​​​​​小樽C 多章⑧ (壹) 指针变量https://blog.csdn.net/weixin_44775255/article/details/129031168 小樽C 多章⑧ (贰) 指针与数组https://blog.csdn.net/weixin_44775255/article/details/129396791 叁、函数与字符串 说道字符串我们要导入字符串库#includecstring 学会字符串的常用方法。strcpystrcmpstrstrstrlen。 //字符串 #includeiostream #includecstdio #includecstring using namespace std; char a[100],b[100]; int main(){strcpy(a,hello); // coutaendl;printf(%s,len%d\n,a,strlen(a)); //字符串长度 scanf(%s,b);int cmp strcmp(a,b); //字符串比较大小 if(cmp0){printf(%s%s\n,a,b);}else if(cmp0){printf(%s%s\n,a,b);}else{printf(%s%s\n,a,b);}if(strstr(a,b)! NULL){ //查找子串 printf(%s in %s\n,b,a); }return 0; } 难点具体来看看strcpy、strlen的来历 #includeiostream #includecstdio #includecstring using namespace std; char *strcpy(char *dest,const char *scr){char *pdest;while(*scr ! \0){*dest *scr;dest;scr;}*dest \0;return p; } int main(){char *anew char;*strcpy(a,cvbnm);coutaendl;*strcpy(a,asd);couta;return 0; } strcpy 是 赋值的含义把某个已知的字符串值赋值到a变量输出a变量就有值了。 #includeiostream #includecstdio #includecstring using namespace std; size_t strlen(const char *str){const char *cp str;while (*cp){;}return (cp-str-1); } int main(){coutstrlen(abcdr)endl; } 这些函数的实现都是指针操作虽然也可以用数组来实现但数组的存储效率会低一些。 肆、函数与指针 4.1 指针作为函数参数 自定义函数的参数可以有整型、浮点型那可不可以用指针类型 那来试试用指针参数实现交换两个变量的值。 例子1.交换两个值再比比大小。 #includeiostream #includecstdio using namespace std; void swap(int *x,int *y){ //交换两个值 int t *x;*x *y;*y t; } void sort(int *x,int *y,int *z){ if(*x *y) swap(x,y); //比大小 if(*x *z) swap(x,z);if(*y *z) swap(y,z); } int main(){int a,b,c;scanf(%d%d%d,a,b,c);sort(a,b,c);printf(a%d,b%d,c%d,a,b,c);return 0; } 4.2 函数返回指针 用指针作为函数, 例如int *a(int a,int b)。 炼1.实现一个包含n个整数的数组中找到第一个质数若有则返回函数的地址没则返回NULL。 #includeiostream #includecstdio #includecmath using namespace std; int n,a[1000]; bool isprime(int n){//求质数 if (n2) return false;if(n2) return true;for(int i2;isqrt(n);i){if(n%i0){return false;}} return true; } int *find(){ //指针查找函数 for(int i1;in;i){if(isprime(a[i])){return a[i];}}return NULL; } int main(){cinn;for(int i1;in;i){cina[i];}int *p find();if(p ! NULL){coutp *p;}return 0; } 4.3 函数指针与函数指针数组 (1) 一般定义函数 int test(int );  那换成指针函数 int (*test)( int );  注意不可以写成 int *test ( int ); 这样子编程会 声明定义成 test ( int )的函数返回类型是 int * 。 (2) 获取函数的地址。 跟数组一样函数名就是地址函数名也可看成是指针。 1.用 typedef 声明函数指针类型 #includeiostream #includecstdio using namespace std; //函数指针 int sum(int a,int b){return ab; } typedef int (*LP)(int,int); //定义声明了LP类型的函数指针内有2个参数。 int main(){LP p sum; // 定义LP类型的指针p coutp(2,5); //函数指针p调用参数return 0; } 2.模拟菜单功能实现例子函数指针数组 //函数指针数组 void t1(){ couttest1endl; } void t2(){ couttest2endl; } void t3(){ couttest3endl; } void t4(){ couttest4endl; } typedef void(*Tp)(); 定义声明了空类型的函数指针 Tp无参数。 int main(){Tp a[] {t1,t2,t3,t4}; 定义TP类型的函数指针数组a int x;cinx;a[x](); return 0; } 4.4 结构体指针  定义一个结构体有名字、性别、成绩成员。声明结构体并赋值还声明结构体指针 #includeiostream #includecstdio using namespace std; struct Student{char name[20];char sex;float score; };Student *p; Student stu{lisi,m,95.5}; 3.指针访问结构体成员方法 (*指针名).成员名  (*p).name指针名-成员名  p-name int main(){coutstu.nameendl;p stu; //指针指向stu地址 cout(*p).nameendl; // (*p).name 效果等同 stu.namecout(*p).sexendl;coutp-score; // p-score 效果等同(*p).scorereturn 0; } 由于一般引用结构体变量通常要对整个的结构体进行引用效率不高所以一般用指针会提高写效率。
http://www.hkea.cn/news/14547919/

相关文章:

  • 保护膜 东莞网站建设asp网站打开很慢的原因
  • 广州市官网网站建设价格怎样增加网站权重
  • 网络编程技术绵竹seo
  • 做logo设计网站鱼台县建设局网站
  • 企业网站该怎么做建筑公司网站平台
  • 各省住房和城乡建设厅网站网络培训总结
  • iview可以做门户网站吗网站服务器和直播服务器一样吗
  • 网站建设技术课程设计报告网站静态界面挖取
  • 做新浪微博网站需要抖音推广平台
  • 东营区住房和城乡建设局网站辛集做网站
  • 电销做网站项目给别人做的网站要复杂做安全扫描
  • 韩国做美食的视频网站有哪些汕头建总
  • 如何用服务器ip地址做网站国内主机wordpress
  • 佛山哪里有做网站的深圳网站seo设计
  • 做seo网站诊断书怎么做网站前台的网址
  • 建立自己的网站用花钱吗图片背景在网站建设中
  • 如何建设一个人工智能网站地产网站开发公司
  • 网站pr查询网络营销优化公司
  • 嘉兴seo网站建设费用wordpress网站名
  • 制作公司网站价格网站开发项目需求书
  • 哪个着陆页网站公司网站建设手续
  • 网站建设推广工资鸿星尔克的网络营销方式
  • 做怎个样网做站个网站制作h5的软件有什么
  • 网站建设wang.cd有什么网站可以做微信支付
  • 热门网站建设加盟平台上海解封最新消息
  • 好看的网站色彩搭配长城建设投资有限公司网站
  • 乐辰科技网站建设网站建设怎么配置伪静态文件
  • 网站建设的财务计划书上海资本公司排名
  • 论述网站建设引言盗用别人公司的产品图片做网站
  • 外冈网站建设台州手机网站制作