c++
huluwadeyeye
。。。。。。。
展开
-
面向对象程序设计上机练习一(函数重载)
#include using namespace std; int f(int s[]) { int i, max = 0; for(i = 0; i { if(s[i] > max) max = s[i]; } return max; } float f(float s[]) {原创 2017-11-07 19:06:54 · 139 阅读 · 0 评论 -
面向对象程序设计上机练习二(函数模板)
#include using namespace std; int f(int s[]) { int i, max = 0; for(i = 0; i { if(s[i] > max) max = s[i]; } return max; } float f(float s[]) {原创 2017-11-07 19:07:50 · 239 阅读 · 0 评论 -
2-2 Time类的定义
#include #include using namespace std; class Time{ public: void settime(int x, int y, int z); void showtime(); private: int hour, minute, sencond; }; void Time::settime(int x, in原创 2017-11-15 22:32:36 · 191 阅读 · 0 评论 -
3-1 Point类的构造函数
#include using namespace std; class Point { private: int m, n; public: Point() { m = 0; n = 0; } Point(int x, int y) { m = x; n =原创 2017-11-16 11:16:06 · 260 阅读 · 0 评论 -
3-4 计算长方形的周长和面积
#include using namespace std; class Rect{ private: double l, w; public: Rect(double length = 0, double width = 0) { l = length; w = width; } Rect(Rect &r原创 2017-11-17 09:40:30 · 360 阅读 · 0 评论 -
4-1 复数类的运算符重载
4-1 复数类的运算符重载 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 通过本题目的练习可以掌握成员运算符重载及友元运算符重载 要求定义一个复数类,重载加法和减法运算符以适应对复数运算的要求,重载插入运算符(以方便输出一个复数的要求。 Input原创 2017-12-11 19:24:56 · 110 阅读 · 0 评论 -
电子时钟中的运算符重载
4-2 电子时钟中的运算符重载 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 通过本题目的练习可以运算符重载的方法; 设计一个时间类Time,私有数据成员有hour(时)、minute(分)、second(秒); 公有成员函数有:setHour(int)设置数据原创 2017-12-18 11:34:08 · 277 阅读 · 0 评论 -
面向对象程序设计上机练习十一(运算符重载)
面向对象程序设计上机练习十一(运算符重载) Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 有两个矩阵a和b,均为2行3列,求两个矩阵之和。重载运算符“+”,使之能用于矩阵相加。如:c=a+b。 Input 第1、2行是矩阵a的值,数据以空格分开。 第3原创 2017-12-27 10:46:51 · 126 阅读 · 0 评论 -
6-1 多态性与虚函数
6-1 多态性与虚函数 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 通过本题目的练习可以掌握多态性的概念和虚函数的定义和使用方法 要求定义一个基类Pet,它有一个成员函数Speak()用于输出pet的叫声。;派生类Dog和Cat从基类Pet派生而来。他们从基类继原创 2017-12-27 11:02:16 · 104 阅读 · 0 评论