![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
代码练习
不过五十步笑百步
这个作者很懒,什么都没留下…
展开
-
设计一个类Date,成员函数实现日期的设置和输出
设计一个类Date,其私有数据成员有year(年)、month(月)、day(日),要求其满足下述要求。 (1)要求有一个无参数的构造函数,其初始的年、月、日分别为:2000,1,1。 (2)要求有一个带参数的构造函数,起参数分别对应年、月、日。 (3)要求用一个成员函数实现日期的设置。 (4)要求 源程序代码: #include <iostream> using namespace std; class Date { private: int y..原创 2022-03-24 19:41:50 · 4162 阅读 · 0 评论 -
求5名学生的最高的分者的学号和姓名 指针做函数参数
#include <iostream> #include <string> using namespace std; class Student { public: string num; string name; float sc; Student() { num = "101"; name = "张三"; sc = 100.0; } Student(string n, str.原创 2022-03-24 18:11:17 · 451 阅读 · 0 评论 -
C++判断点和圆心的位置 类、构造函数、函数
#include <iostream> #include<cmath> using namespace std; //输入一个坐标和已知圆心的圆,判断点和圆心的位置 //点类 class point { public: double p_x; double p_y; }; //圆类 class circle { public: //内构函数 初始化圆心为(1,1) circle() { po.p_x = 1.0; po.p_y = 1.0; } //判断点.原创 2022-03-14 20:00:46 · 975 阅读 · 0 评论 -
(英雄-按年龄排序)结构体数组初始化 冒泡排序
#include <iostream> #include<ctime> #include<cmath> #include<string> using namespace std; struct hero { string name; int age; string six; }; void print(hero h[], int len) { for (int i = 0; i < len; i++) { cout << ".原创 2022-01-22 10:46:32 · 234 阅读 · 0 评论 -
结构体运用 打印三个老师姓名并各带五个学生name score
使用了随机数,结构体嵌套。 //结构体运用 //打印三个老师并各带五个学生name score #include <iostream> #include<ctime> #include<cmath> #include<string> using namespace std; struct student { string sname; int score; }; struct teacher { string tname; struct stu.原创 2022-01-22 10:04:20 · 360 阅读 · 0 评论 -
函数、数组和指针结合
//函数 数组 指针 #include <iostream> #include<ctime> #include<cmath> using namespace std; void bubble_sort(int *a, int len) { for (int i = 0; i <len-1; i++) { for (int j = 0; j < len-1- i; j++) { if (a[j] > a[j + 1]) { .原创 2022-01-20 10:29:39 · 408 阅读 · 0 评论