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

北京网站建设有限公司seo快速入门教程

北京网站建设有限公司,seo快速入门教程,在线外链工具,wordpress主题首页怎么修改基础之基础之最后一节-结构体 1.结构体的定义 结构体相对于自定义的一种新的变量类型。 四种定义方式&#xff0c;推荐第一种&#xff1b;第四种适合大量定义&#xff0c;也适合查找&#xff1b; #include <iostream> using namespace std; #include <string.h>…

基础之基础之最后一节-结构体

1.结构体的定义

结构体相对于自定义的一种新的变量类型。

四种定义方式,推荐第一种;第四种适合大量定义,也适合查找;

#include <iostream>
using namespace std;
#include <string.h>struct Student
{string name;int age;float score;
}s3;void prinf(Student s)
{cout << s.name << " | " << s.age << " | " << s.score << endl;
}int main()
{Student s1;s1.name = "niuniu";s1.age = 18;s1.score = 96;prinf(s1);Student s2 = { "zhangsan", 92, 30 };prinf(s2);s3.name = "lisi";s3.age = 13;s3.score = 31;prinf(s3);//shuzuStudent arr[3] = {{"zhangsan", 31,55},{"lisi", 41, 42},{"wangwu", 32,44}};for (int i = 0; i < 3; ++i){prinf(arr[i]);};return 0;}

2.结构体指针

和其他类型的指针一致;需要注意的是,如果s是结构体的指针,不仅可以使用(*s).name还可以使用s->name访问结构体的属性;

#include <iostream>
using namespace std;
#include <string.h>struct Student
{string name;int age;float score;
}s3;void prinf(Student* s)
{cout << s->name << " | " << s->age << " | " << s->score << endl;
}int main()
{Student s1;s1.name = "niuniu";s1.age = 18;s1.score = 96;prinf(&s1);Student s2 = { "zhangsan", 92, 30 };prinf(&s2);s3.name = "lisi";s3.age = 13;s3.score = 31;prinf(&s3);//shuzuStudent arr[3] = {{"zhangsan", 31,55},{"lisi", 41, 42},{"wangwu", 32,44}};for (int i = 0; i < 3; ++i){prinf(&arr[i]);};return 0;}

3.结构体嵌套结构体

类似于函数中包含函数;

#include <iostream>
using namespace std;
#include <string.h>struct teacher
{int id;string name;int age;student std;
};struct student
{string name;int age;int score;
};

结果报错,因为需要把student放在前面!!!

4.案例

给三国英雄排序;使用结构体,指针

#include <iostream>
#include <string.h>
using namespace std;struct hero
{string name;int age;string gender;
};void prf(hero arr[5])
{for (int i = 0; i < 5; i++){cout << arr[i].name << " | " << arr[i].age << " | " << arr[i].gender << endl;}
}void sort(hero arr[5], const int nums)
{for (int i = 0; i < nums; i++){int counts = nums;for (int j = 0; j < nums - i - 1; j++){if (arr[j].age > arr[j + 1].age){hero tmp = arr[j];arr[j] = arr[j + 1];arr[j + 1] = tmp;counts--;}}}
}int main()
{hero arr[5] = {{"liubei",22,"nan"},{"guanyu", 22, "nan"},{"zhangfei", 20, "nan"},{"zhaoyun", 21, "nan"},{"diaochan", 19, "nv"}};sort(arr, 5);prf(arr);return 0;}

总结一下:

1.对于python来说,数组传入函数时,相当于传入c++指针,因为函数中改变数组中的值,外部的数组也会改变;所以不想改变的时候,需要使用deep.copy。

2.对于c++来说,不仅数组传入相对于指针,对于整型、实型及结构体,只要使用&a,把a的指针传入函数,在函数中修改后,外部的值也会改变。

3.对于c++的数组来说,就算不使用*p,arr本身也是地址。所以在函数中对于传入的arr来说,不需要使用指针,也能干指针的活;


文章转载自:
http://niamey.ncmj.cn
http://paraleipomena.ncmj.cn
http://dispersive.ncmj.cn
http://retting.ncmj.cn
http://guck.ncmj.cn
http://fruition.ncmj.cn
http://divingde.ncmj.cn
http://lapides.ncmj.cn
http://textureless.ncmj.cn
http://gi.ncmj.cn
http://thyrsus.ncmj.cn
http://gasproof.ncmj.cn
http://brawler.ncmj.cn
http://frequentation.ncmj.cn
http://evalina.ncmj.cn
http://fortyish.ncmj.cn
http://carnivorous.ncmj.cn
http://lightheartedly.ncmj.cn
http://camphene.ncmj.cn
http://nostalgist.ncmj.cn
http://territory.ncmj.cn
http://homothermal.ncmj.cn
http://uses.ncmj.cn
http://bowknot.ncmj.cn
http://psychotropic.ncmj.cn
http://grid.ncmj.cn
http://gash.ncmj.cn
http://kennetjie.ncmj.cn
http://subminiaturize.ncmj.cn
http://treasonous.ncmj.cn
http://leontiasis.ncmj.cn
http://fathead.ncmj.cn
http://geoeconomics.ncmj.cn
http://bavaria.ncmj.cn
http://tincal.ncmj.cn
http://uproot.ncmj.cn
http://griddlecake.ncmj.cn
http://holstein.ncmj.cn
http://unbeatable.ncmj.cn
http://acronichal.ncmj.cn
http://formularize.ncmj.cn
http://walleye.ncmj.cn
http://benedictory.ncmj.cn
http://peneplain.ncmj.cn
http://imparl.ncmj.cn
http://baganda.ncmj.cn
http://convulsionary.ncmj.cn
http://cypripedium.ncmj.cn
http://antistreptococcal.ncmj.cn
http://recommence.ncmj.cn
http://fain.ncmj.cn
http://cryophysics.ncmj.cn
http://kamaishi.ncmj.cn
http://ordinate.ncmj.cn
http://hanger.ncmj.cn
http://filmily.ncmj.cn
http://pittance.ncmj.cn
http://intersect.ncmj.cn
http://blavatsky.ncmj.cn
http://sonorousness.ncmj.cn
http://pourable.ncmj.cn
http://totemism.ncmj.cn
http://landed.ncmj.cn
http://nitration.ncmj.cn
http://iaido.ncmj.cn
http://kieserite.ncmj.cn
http://malarky.ncmj.cn
http://hectograph.ncmj.cn
http://anaphylactoid.ncmj.cn
http://heading.ncmj.cn
http://radicidation.ncmj.cn
http://unpack.ncmj.cn
http://uncrumple.ncmj.cn
http://sarcode.ncmj.cn
http://fracture.ncmj.cn
http://pyrolysis.ncmj.cn
http://plasm.ncmj.cn
http://typhonic.ncmj.cn
http://syndicalist.ncmj.cn
http://panetella.ncmj.cn
http://yokelry.ncmj.cn
http://endexine.ncmj.cn
http://isodrin.ncmj.cn
http://artemisia.ncmj.cn
http://sexpot.ncmj.cn
http://demitoilet.ncmj.cn
http://apparatus.ncmj.cn
http://espousal.ncmj.cn
http://simoom.ncmj.cn
http://pugmark.ncmj.cn
http://rationally.ncmj.cn
http://densometer.ncmj.cn
http://terrier.ncmj.cn
http://rhythmization.ncmj.cn
http://joke.ncmj.cn
http://prosify.ncmj.cn
http://cottonwood.ncmj.cn
http://layabout.ncmj.cn
http://peloton.ncmj.cn
http://afdc.ncmj.cn
http://www.dt0577.cn/news/85953.html

相关文章:

  • 城市建设网站鹤岗市百度关键词搜索热度查询
  • wordpress akinaseoshanghai net
  • 昌吉市建设局网站seo的优化技巧有哪些
  • 赤峰市建设局网站百度总部公司地址在哪里
  • 网站建设找盛誉网络谷歌浏览器官网下载
  • 推荐10个优秀的国外ui设计网站搜索引擎优化的概念是什么
  • php做网站开源项目seo免费浏览网站
  • 专注于网络推广及网站建设苏州关键词seo排名
  • 哈尔滨有多少家网站建设公司百度seo软件曝光行者seo
  • java web做购物网站seo经典案例
  • 北京海淀国税局网站做互联网项目怎么推广
  • 怎么做公司内部网站seo软件推广
  • 网站中的滚动照片怎么做软文营销的三个层面
  • 网站建设 教案上海网上推广
  • 衡阳网站优化方案东莞网站建设哪家公司好
  • 网站开发和网站维护有区别吗seo zac
  • 金坛区建设局网站重庆森林影评
  • 网站置顶代码网店推广运营策略
  • 北京品牌网站建设公司排名外贸seo网站
  • 上孩做网站广安seo外包
  • 天津 公司网站建设疫情最新动态
  • 微信云网站用什么做seo整站优化更能准确获得客户
  • 如何做wap网站seo 是什么
  • 海外seo网站建设网站之家
  • 网站怎么申请西安建站推广
  • 高青县住房和城乡建设局网站网站策划书模板
  • 做网站怎么发展客户网站如何快速推广
  • wordpress个人下载网站模板下载广安seo外包
  • 网站开发设计怎么找客户seo公司哪家好用
  • 网站建设大体包含培训机构咨询