
C语言
HTF流年
这个作者很懒,什么都没留下…
展开
-
(C/C++)Set类(集合)
Set类(集合)题目:#include using namespace std;class Set{private:int n;int * pS; //集合元素public:Set(){n = 0;pS =NULL;}Set(Set &s){n = s.n;if (n !=0){pS= new int[n+1];for (int i =1;i<=n;i...原创 2019-12-28 16:54:55 · 2522 阅读 · 0 评论 -
(C/C++)完成Location类
完成Location类题目:#include using namespace std;class Location{public:Location(int xx,int yy){x =xx;y =yy;}Location &operator +(Location &offset);Location &operator -(Location &of...原创 2019-12-28 16:43:54 · 1536 阅读 · 0 评论 -
(C/C++)重载《运算符
重载《运算符题目:重载运算符 << ,使之能够使用cout将Date类对象的只以日期格式输出,Date类的定义如下,在你的代码中需包含Date类的定义和实现。class Date{public:Date(int y=1996,int m=1,int d=1){day = d;month = m;year = y;if (m>12 || m<1){mon...原创 2019-12-28 16:41:57 · 1755 阅读 · 0 评论 -
(C/C++)扩展String类
扩展String类题目:扩展String类,引入头文件CString.h,它的内容如下:#include using namespace std;class String{protected:char *mystr;int len;public:String(const char *p){len = strlen§;mystr = new char[len+1];strcp...原创 2019-12-28 16:39:41 · 1281 阅读 · 1 评论 -
(C/C++)实现User类
实现User类题目:设计一个User类,要求User类可以保持多个用户的用户名和密码信息,实现User类的构造函数和AddUser方法添加新用户,实现int login(char *name,char * pass)方法,该方法接受用户名和密码,判断用户名对应的密码是否正确,如果正确返回用户的编号,如果不正确返回-1。User类的使用示意如下所示,在你的代码中除了实现User类以外,还...原创 2019-12-20 14:51:34 · 3638 阅读 · 0 评论 -
(C/C++)实现Clock类
实现Clock类题目:实现时钟类Clock,(24小时制,0~23)在代码中引入头文件 Clock.h它的定义如下:#include using namespace std;class Clock{public:Clock(int h,int m, int s);void SetAlarm(int h,int m,int s);void run();void ShowTim...原创 2019-12-20 14:39:25 · 6050 阅读 · 1 评论 -
(C/C++)实现Student类
实现Student类题目:设计一个学生类Student,包含学生学号(最长10位)、姓名(不用支持中文最长12位)、三门课程成绩等基本信息,计算每门课程学生的平均成绩。需实现Student的display成员函数,依次输出学号 姓名 和三门课的成绩,每个输出以空格隔开成员函数 average1 ,average2 ,average3 ,分别返回三门课的平均成绩。Student类的使用方法...原创 2019-12-20 14:32:25 · 4738 阅读 · 0 评论 -
(C/C++)实现Date类
实现Date类题目:实现日期类Date,它能正确表示年、月、日。在代码中引入头文件 CDate.h它的内容如下:class Date{public:Date(int y =1996,int m=1,int d=1){};int days(int year,int month){};void NewDay();void display(){cout<<year&l...原创 2019-12-20 14:27:14 · 1686 阅读 · 0 评论 -
(C/C++)实现三角形类
实现三角形类题目:实现一个三角形类 Ctriangle该类有一个GetPerimeter方法返回三角形的周长;GetArea方法返回三角行的面积;该类还提供一个display方法显示三角形的三边长度;最终在main函数中生成该类,输入三条边的长度(不用考虑三条边不能构成三角形的情况);展示三角形的三边长度以及周长和面积Ctriangle类的使用如下,在你的代码中除了实现Ctrian...原创 2019-12-20 14:18:07 · 3375 阅读 · 0 评论