- 博客(14)
- 收藏
- 关注
原创 第六周作业
//【任务4】设计一个三角形类,能够输入三角形的三个顶点,求出其面积、周长,并判断其是否为直角三角形和等腰三角形。 提示:(1)这个问题需要用到两个类,顶点类参照任务3中的CPoint类;(2)三角形类参考下面CTriangle类的声明;(3)充分利用CPoint类中已有的代码实现;(4)关于三条边的处理,可以增加三个私有属性,在初始化时求出来备用,也可以在需要时计算得到。*/ #include
2012-03-28 20:44:18 376
原创 第六周作业
//【任务3】设计平面坐标点类,计算两点之间距离、到原点距离、关于坐标轴和原点的对称点等 #include #include"cmath" using namespace std; enum SymmetricStyle {axisx, axisy, point};//分别表示按x轴, y轴, 原点对称 class CPoint { private: double x; // 横坐标
2012-03-28 20:38:50 310
原创 第六周作业
a. 用指针访问对象 #include using namespace std; class A { private: int a; public: A() {a=5;} A(int aa) : a(aa){}; //定义构造函数,用参数aa初始化数据成员a void display() { cout << a << endl; } }; int main() {
2012-03-28 20:34:50 312
原创 第五周作业
#include using namespace std; class student { public: student(int n = 0, float sc = 60) : num(n), score(sc){};//用参数的初始化表对数据成员初始化。 void max(student *arr); void display(); private: int num; int s
2012-03-21 20:19:04 348
原创 第五周作业3
#include using namespace std; class Box { public: Box(int h =8, int w = 8, int len = 9) : heigth(h), width(w), length(len){};//声明有默认参数的构造函数,用参数初始化表对数据成员初始化 int volume(); int area(); void inpu
2012-03-21 20:16:06 331
原创 第五周作业2
#include using namespace std; class CFraction { private: int nume; // 分子 int deno; // 分母 public: CFraction(int nu=0, int de=1) : nume(nu), deno(de){}; //构造函数,初始化用 //void Set(int nu=0,int de
2012-03-21 20:12:44 395
原创 第五周作业1
#include #include using namespace std; class Triangle { public: Triangle(float x, float y, float z) : a(x), b(y), c(z){}; float Perimeter(void);//计算三角形的周长 float Area(void);//计算并返回三角形的面积 void sh
2012-03-21 20:09:48 544 1
原创 第四周作业2
//设计一个“正整数”类,并通过一系列的成员函数对其性质进行做出判断或列出相关联的数值。下面给出类声明,请实现各成员函数。另外,模仿已经给出的main()函数,完成你所设计的各个成员函数的测试。 #include using namespace std; class NaturalNumber {private: int n; public: void setValue (int x)
2012-03-17 10:08:23 408
原创 第四周作业1
//【任务1】下面设计一个三角形类,请给出各成员函数的定义 #include #include using namespace std; class Triangle { public: void Setabc(float x, float y, float z);//置三边的值,注意要能成三角形 void Getabc(float *x,
2012-03-14 21:07:33 431
原创 作业
#include using namespace std; class Time { public: void set_time(); void show_time(); inline add_a_sec(); inline add_a_minute(); inline add_a_hour();//内置函数,增加一秒
2012-03-14 20:56:52 359
原创 递归十化二
#include using namespace std; void d2b(int n) { if(n==0) { cout<<"0"; } else { d2b(n/2); cout<<n%2; } } int main() { int a; c
2012-03-10 13:30:12 351
原创 改错
#include using namespace std; class Time { public: void set_time(void); void show_time(void); private: int hour; int minute; int sec; }; Time t;
2012-03-10 13:17:22 430
原创 作业3
#include #include "string.h" using namespace std; int main() { char str[200]; cin.get(str, 100, '\n'); for(int i = 0, j = 0; str[i] != '\0';) { j++; i++ }
2012-03-10 12:48:59 603 1
原创 作业
#include using namespace std; long fac(int n) { for(int i = 1, sum = 1; i <= n; ) { sum = sum * i; i++; } return sum; } int main() { int C, m,
2012-03-10 12:38:30 357
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人