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

做网站的网络非要专线吗百度引擎搜索引擎入口

做网站的网络非要专线吗,百度引擎搜索引擎入口,360网站建设商家,网站建设专题页面一、实验目的: 掌握类中静态成员的定义方法,初始化方法,使用方法; 掌握类的友元说明方法,理解友元的使用特点 二、实验内容: 1、编写程序,统计某旅馆住宿客人的总数,要求输入客人…

一、实验目的:

掌握类中静态成员的定义方法,初始化方法,使用方法;
掌握类的友元说明方法,理解友元的使用特点

二、实验内容:

1、编写程序,统计某旅馆住宿客人的总数,要求输入客人姓名,输出客人编号(按先后顺序自动生成),姓名以及总人数。

在这里插入图片描述

#include<iostream>
#include<stdlib.h>
#include<iomanip>
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 <algorithm>using 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::vector<Stu> 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;cin>>n;for(int i=0;i<n;i++)cin>>x,a.arr[i]=x;Array b(a);for(int i=0;i<n;i++)cout << b.arr[i] << " " ;return 0;
}

2、已知三点座标,求三角形的面积。
在这里插入图片描述

#include <iostream>
#include <cmath>using 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 ;cin>>x1>>y1;cin>>x2>>y2;cin>>x3>>y3;double area = getTriangleArea(x1, y1, x2, y2, x3, y3);cout << "Triangle area is: " << area << endl;return 0;
}
http://www.yayakq.cn/news/200240/

相关文章:

  • 企业网站如何建设和推广优化网站是什么意思
  • 哪个网站是可以做书的wordpress弹窗提示
  • 手机网站的好处9个常用的wordpress sql查询命令
  • 网站建设软件开发本土广告公司
  • 建立团购网站三折页宣传册设计
  • 厦门网站备案大连建设网交费查询
  • 西安免费网站搭建制作网络项目实施方案
  • 做网签合同的网站是瑞昌市环保局网站建设
  • 金华高端网站建设公司小辰青岛网站建设
  • 网站建设:成都今网科技宁波开发网络推广平台
  • 在哪家网站做淘宝客最好dedecms怎么关闭网站
  • 湖北省住房和城乡建设部门户网站那个视频网站可以做gif
  • 免费室内设计网站都有哪些wordpress 在线课程主题
  • 微小店网站建设多少钱中山做网站哪个公司好
  • 文化网站前置审批合肥网站建设+一浪
  • 东莞专业网站建设公司万网网
  • 微商怎么做 和淘宝网站一样吗网站建设动画教程
  • 女人动漫做受网站seo排名优化什么意思
  • 网站注销申请书网盟推广是什么
  • 胶南网站建设多少钱做的网站响应速度慢
  • 凡客网站做SEO能被收录吗网站域名归属权
  • 广东高端网站建设公司wordpress 删除示例页面
  • 景德镇陶瓷企业网站建设成都网站建设十强企业
  • wap网站前台模板大数据在营销中的应用案例
  • 贵阳公司官方网站建设易站网站建设
  • 网站创建设计SEO优化象客怎么把网站做的好看
  • 电子商务网站建设和运营WordPress自适应扁平化
  • 深圳龙岗网站开发罗源做网站的公司
  • 中山网站建设联系电话网站备案信息代码在哪里找
  • 中国建设网站用户名wordpress后台访问卡