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

东莞网站建设 织梦建设茶叶网站的目的

东莞网站建设 织梦,建设茶叶网站的目的,免费dns解析服务器,潍坊网站seo一、实验目的#xff1a; 掌握类中静态成员的定义方法#xff0c;初始化方法#xff0c;使用方法#xff1b; 掌握类的友元说明方法#xff0c;理解友元的使用特点 二、实验内容#xff1a; 1、编写程序#xff0c;统计某旅馆住宿客人的总数#xff0c;要求输入客人…一、实验目的 掌握类中静态成员的定义方法初始化方法使用方法 掌握类的友元说明方法理解友元的使用特点 二、实验内容 1、编写程序统计某旅馆住宿客人的总数要求输入客人姓名输出客人编号按先后顺序自动生成姓名以及总人数。 #includeiostream #includestdlib.h #includeiomanip using namespace std; struct ListPeople {int num;string name;struct ListPeople* next;ListPeople(int num, string name){this-num num;this-name name;} }; void sumpeople(ListPeople* m)//输出总人数 {int sum 0;while (m-next ! NULL){sum;m m-next;}cout 总人数为 sum 人 endl; } int main() {int num 0;string name ;ListPeople* head new ListPeople(num, name);head-next NULL;int number 0;cout 输入0查看客人总数 endl;cout 输入1客人入住 endl;cout 输入2客人退房 endl;cout 输入-1退出 endl;while (number ! -1){cout 请输入编号;cin number;switch (number){case 0://输出总人数{sumpeople(head);break;}case 1://客人入住{cout 请输入入住客人姓名;cin name;num;ListPeople* q new ListPeople(num, name);ListPeople* p head;while (p-next ! NULL)p p-next;p-next q;q-next NULL;cout 客人编号为 setw(4) setfill(0) q-num 客人姓名为 q-name endl;sumpeople(head);break;}case 2://客人退房{ListPeople* m head;int flag 0;if (m-next NULL){cout 目前没有客人入住无法退房 endl;break;}cout 请输入退订客人姓名;cin name;while (m-next ! NULL){if (m-next-name name){ListPeople* d m-next;m-next m-next-next;delete d;cout 客人退订成功 endl;sumpeople(head);flag 1;break;}m m-next;}if (flag 0)cout 未查找到该客人 endl;break;} default:if (number ! -1)cout 请重新输入 endl;elsecout 已退出 endl;}} return 0; }2、编写学生类Stu包含学生姓名成绩设计一个友员函数将学生成绩按大到小排序。 #include iostream #include vector #include algorithmusing namespace std; class Stu { private:string name;float score; public:Stu(string name, float score) : name(name), score(score) {}friend bool operator(const Stu s1, const Stu s2);void print() {cout Name: name , Score: score endl;} }; bool operator(const Stu s1, const Stu s2) {return s1.score s2.score; } int main() {std::vectorStu students;// 添加学生信息students.push_back(Stu(Tom, 85.5));students.push_back(Stu(Alice, 92.0));students.push_back(Stu(John, 78.5));students.push_back(Stu(Emma, 95.0));// 按成绩排序std::sort(students.begin(), students.end());// 输出排序结果for (auto it : students) {it.print();}return 0; }1、编写整型数组类 arrow能创建任意长度数组对象用深复制 #include iostream #include cstring using namespace std;class Array { public:int* arr;int size;Array(int length) {size length;arr new int[length];}Array(const Array a) {size a.size;arr new int[size];memcpy(arr, a.arr, size*sizeof(int)); }~Array() {delete[] arr;} };int main() {Array a(5);int n;int x;cinn;for(int i0;in;i)cinx,a.arr[i]x;Array b(a);for(int i0;in;i)cout b.arr[i] ;return 0; }2、已知三点座标求三角形的面积。 #include iostream #include cmathusing namespace std;double getTriangleArea(int x1, int y1, int x2, int y2, int x3, int y3) {double a sqrt((x2-x1)*(x2-x1) (y2-y1)*(y2-y1));double b sqrt((x3-x2)*(x3-x2) (y3-y2)*(y3-y2)); double c sqrt((x1-x3)*(x1-x3) (y1-y3)*(y1-y3));double s (a b c) / 2;return sqrt(s*(s-a)*(s-b)*(s-c)); }int main() {int x1 , y1 ;int x2 , y2 ; int x3 , y3 ;cinx1y1;cinx2y2;cinx3y3;double area getTriangleArea(x1, y1, x2, y2, x3, y3);cout Triangle area is: area endl;return 0; }
http://www.zqtcl.cn/news/970421/

相关文章:

  • 做网站的背景图片要多大做房产网站
  • 洛阳做网站公司在哪无锡网络营销推广软件
  • 医疗机械网站怎么做无锡短视频seo
  • 做网站建设哪家公司好如何营销推广
  • 陕西百威建设监理有限司网站做吉祥物设计看什么网站
  • 网络营销站点推广的方法高端网站开发价格
  • 内部优惠券网站怎么做最新国际新闻事件今天
  • 辽宁大学网站怎么做app开发用什么编程语言
  • 3d建模在线制作网站阿里云域名注册官网
  • 创建网站大约多少钱网站建设排序题
  • 大庆做网站找谁机构编制网站建设
  • 网站标题特效网站弹出的对话框怎么做
  • 找深圳网站建设wordpress 页面背景
  • 企业网站怎么维护上海注册建网站
  • 四川省建设工程造价信息网站便宜做网站价格
  • 医院网站优化策划网站开发的项目需求
  • 网站优化公司服务直播软件怎么开发
  • 网站建设 有道翻译织梦修改网站后备份
  • 苏州网联盛网站建设做最好的在线看片网站
  • 一个空间怎么放2个网站陕西城乡住房建设部网站
  • 如何购买虚拟主机做网站企业查名
  • 动易网站默认密码网站怎么做 吸引人
  • 站长工具国产2023二级建造师证书查询官方网站
  • 微信小程序联盟网站北京网站建设华大
  • 人事怎么做招聘网站比对分析crm管理系统 一般包含
  • 林业网站建设有哪些北京微信小程序开发
  • ppt素材网站建设流程图网站开发原型工具
  • 乡镇医院网站建设成都市企业网站建设
  • 网站编辑如何做原创网站中英切换实例
  • 哈尔滨道外区建设局官方网站wordpress简称