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

更换网站需要怎么做推广之家app

更换网站需要怎么做,推广之家app,学校网站怎么查询录取,现代网站开发设计报告基础之基础之最后一节-结构体 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://www.hkea.cn/news/180964/

相关文章:

  • 怎么做外贸个人网站seo综合查询工具可以查看哪些数据
  • 黑客网站盗qq百度seo公司整站优化
  • 网页设计代码不能运行seo的中文名是什么
  • 灵溪网站建设外贸网站谷歌seo
  • 网站开发系统设计产品推销
  • 不用代码做网站 知乎百度引流推广怎么收费
  • 怎么看网站后台什么语言做的产品全网营销推广
  • 可以做宣传图的网站网络销售管理条例
  • 做书籍封皮的网站制作网站平台
  • 1网站建设公司长沙网站到首页排名
  • 域名还在备案可以做网站吗seo培训班
  • 前程无忧网宁波网站建设类岗位北京网站快速排名优化
  • 如何优化网站内部链接站长工具站长之家
  • 阿里云网站建设的实训报告免费的自媒体一键发布平台
  • 关于加强网站建设的意见企业获客方式
  • 帮企业建设网站保密合同优化设计电子课本
  • 金山石化网站建设广告电话
  • 网站开发 前景网络推广代理
  • 温州整站推广咨询seo网站推广专员
  • 企业营销型网站团队百度seo排名优化教程
  • 安徽平台网站建设哪里好网络策划与营销
  • 做网站接广告赚钱么凡科建站和华为云哪个好
  • 成都网站建设科技公seo营销外包公司
  • 重庆有哪些做网站 小程序的百度搜索引擎的特点
  • 仁怀哪里可以做网站自动秒收录网
  • 重庆市建设局网站推广软件一键发送
  • 合肥网络推广网络运营网站seo诊断分析和优化方案
  • 网站优化公司免费咨询sem优化推广
  • 个人做网站赚钱么宁波seo推荐推广平台
  • 员工支付做网站的费用分录成都营销型网站制作