摘要: 三天打鱼两天晒网问题 1 #include <iostream> 2 using namespace std; 3 class Date{ 4 public: 5 int year,month,day; 6 Date(int y,int m,int d):year(y),month(m),day(d 阅读全文
posted @ 2023-05-09 21:12 新晋软工小白 阅读(70) 评论(0) 推荐(0)
摘要: 1,百钱买百鸡问题 1 #include <iostream> 2 using namespace std; 3 int main() 4 { 5 int x,y,z; 6 for(int x=0;x<=20;x++) 7 { 8 for(int y=0;y<=33;y++) 9 { 10 for( 阅读全文
posted @ 2023-05-08 20:57 新晋软工小白 阅读(492) 评论(0) 推荐(0)
摘要: 1 #include<iostream> 2 using namespace std; 3 class Time 4 { 5 private: 6 int hh; 7 int mm; 8 int ss; 9 public: 10 Time() 11 { 12 hh = 0; 13 mm = 0; 1 阅读全文
posted @ 2023-05-07 20:44 新晋软工小白 阅读(37) 评论(0) 推荐(0)
摘要: 复数类Complex有两个数据成员:a和b, 分别代表复数的实部和虚部,并有若干构造函数和一个重载-(减号,用于计算两个复数的距离)的成员函数。 要求设计一个函数模板 template < class T > double dist(T a, T b) 对int,float,Complex或者其他类 阅读全文
posted @ 2023-05-06 22:00 新晋软工小白 阅读(49) 评论(0) 推荐(0)
摘要: 第一个例题。 #include <iostream> using namespace std; template<class T> T abs(T s) { return s<0 ? -s : s; } int main(){ int n=-5; double d=-5.5; cout<<abs(n 阅读全文
posted @ 2023-05-05 21:24 新晋软工小白 阅读(47) 评论(0) 推荐(0)
摘要: 定义一个CPU类 1 #include <iostream> 2 using namespace std; 3 enum Core{ 4 Single,Dual,Quad 5 }; 6 enum Words{ 7 Bits32,Bits64 8 }; 9 enum HyperThread{ 10 S 阅读全文
posted @ 2023-05-04 20:41 新晋软工小白 阅读(19) 评论(0) 推荐(0)
摘要: 1 #include <iostream> 2 using namespace std; 3 enum weekday{sunday,monday,tuesday,wednesday,thursday,friday,saturday 4 }; 5 int main() 6 { 7 int i; 8 阅读全文
posted @ 2023-04-27 22:00 新晋软工小白 阅读(9) 评论(0) 推荐(0)
摘要: 定义一个Circle类,有半径数据成员,有求面积函数,构造一个Circle对象测试。 1 #include <iostream> 2 using namespace std; 3 #define PI 3.1415926 4 class Circle{ 5 private: 6 double rad 阅读全文
posted @ 2023-04-26 20:56 新晋软工小白 阅读(96) 评论(0) 推荐(0)
摘要: 定义一个datatype类,能处理包含字符型,整形,浮点型3种类型的数据,给出其构造函数。 1 #include <iostream> 2 using namespace std; 3 4 class DataType{ 5 private: 6 char a; 7 int n; 8 float x 阅读全文
posted @ 2023-04-25 20:50 新晋软工小白 阅读(30) 评论(0) 推荐(0)
摘要: #include <iostream> using namespace std; class Date{ private: int year,month,day; public: Date(int year=1,int month=1,int day=1) { this->year=year; th 阅读全文
posted @ 2023-04-24 20:57 新晋软工小白 阅读(22) 评论(0) 推荐(0)