- 博客(52)
- 收藏
- 关注
原创 P269 6
#include #include using namespace std; struct student {int num; char name[20]; double score; };int main() {student stud[3]={1001,"Li",78,1002,"Wang",89.5,1004,"Fun",90},stud1[3]; char c[
2015-06-10 20:01:15
466
原创 P269 5
#include #include using namespace std; struct staff {int num; char name[20]; int age; double pay; }; int main() {staff staf[7]={2101,"Li",34,1203,2104,"Wang",23,674.5,2108,"Fun",54,77
2015-06-10 19:58:28
391
原创 P269 3
#include #include using namespace std; int main() { for(int n=1;n<8;n++) cout<<setw(20-n)<<setfill(' ')<<" "<<setw(2*n-1)<<setfill('B')<<"B"<<endl; return 0; }
2015-06-10 19:49:54
351
原创 P269 2
#include #include using namespace std; int main() {float a[5];cout<<"input data:";for(int i=0;i<5;i++) cin>>a[i]; cout<<setiosflags(ios::fixed)<<setprecision(2); for(i=0;i<5;i++) cout<<s
2015-06-10 19:47:41
450
原创 P268 1
#include #include using namespace std; int main() {double a,b,c,s,area; cout<<"please input a,b,c:"; cin>>a>>b>>c;if (a+b<=c)cerr<<"a+b<=c,error!"<<endl; else if(b+c<=a)cerr<<"b+c<=a,err
2015-06-10 19:44:57
491
原创 P225 5
#include using namespace std;//定义抽象基类Shape class Shape {public: virtual double area() const =0;//纯虚函数};//定义Circle(圆形)类class Circle:public Shape {public: Circle(double r):radius(r){}//结构函数v
2015-06-10 19:40:53
482
原创 P225 4
#include using namespace std; //定义抽象基类Shape class Shape {public: virtual double area() const =0;//纯虚函数};//定义Circle类class Circle:public Shape {public: Circle(double r):radius(r){}//结构函数virt
2015-06-10 19:26:59
307
原创 P225 3
#include using namespace std; class Point {public: Point(float a,float b):x(a),y(b){} ~Point(){cout<<"executing Point destructor"<<endl;} private: float x; float y; }; class Circle:public
2015-06-10 19:17:28
297
原创 研究生类
#include #include using namespace std; class Student { public: virtual void get()=0; virtual void display()=0; string name; int num; }; class UGraduate :public St
2015-06-02 18:37:01
546
原创 课堂题目修改
//扩展程序:创建一个三角形类 //修改create_object函数,使得程序支持三角形的创建 //和求面积、打印等操作 #include using namespace std; class Shape { public: virtual double getArea() const = 0; virtual void print() c
2015-05-25 21:33:55
413
原创 P202 10
#include #include using namespace std; class Teacher //教师类{public: Teacher(int,char [],char); //声明构造函数void display(); //声明输出函数private: int num; char name[20]; char sex; }; Teacher::T
2015-05-18 13:09:04
318
原创 P202 9
#include #include using namespace std; class Teacher {public: Teacher(string nam,int a,char s,string tit,string ad,string t); void display(); protected: string name; int age; char sex; st
2015-05-18 13:08:15
283
原创 P201 8
#include using namespace std; class A { public: A(){cout<<"constructing A "<<endl;} ~A(){cout<<"destructing A "<<endl;} }; class B : public A { public: B(){cout<<"constructing B "<<endl
2015-05-18 13:07:56
718
原创 P200 7
#include using namespace std; class A { public: A(){a=0;b=0;} A(int i){a=i;b=0;} A(int i,int j){a=i;b=j;} void display(){cout<<"a="<<a<<" b="<<b;} private: int a; int b; }; class B :
2015-05-18 13:07:08
615
原创 P198 4
#include using namespace std; class Student//声明基类{public: //基类公用成员void get_value(); void display( ); protected : //基类保护成员int num; char name[10]; char sex; }; void Student::get_value(
2015-05-18 13:06:12
366
原创 P198 3
#include using namespace std; class Student //声明基类{public: //基类公用成员void get_value(); void display( ); protected : //基类保护成员int num; char name[10]; char sex; }; void Student::get_value()
2015-05-18 13:05:25
349
原创 P198 2
#include using namespace std; class Student {public: void get_value() {cin>>num>>name>>sex;} void display( ) {cout<<"num: "<<num<<endl; cout<<"name: "<<name<<endl; cout<<"sex: "<<sex<<end
2015-05-18 13:03:57
293
原创 P198 1
#include using namespace std; class Student {public: void get_value() {cin>>num>>name>>sex;} void display( ) {cout<<"num: "<<num<<endl; cout<<"name: "<<name<<endl; cout<<"sex: "<<sex<<en
2015-05-18 13:03:23
318
原创 时间相加
#includeusing namespace std; #include class Time { public: void display(){cout<<hour<<":"<<minute<<":"<<sec<<endl;} protected: int hour; int minute; int sec; };clas
2015-05-11 22:59:57
359
原创 P153 7
#include using namespace std; class Student {public: Student(int,char[],char,float); int get_num(){return num;} char * get_name(){return name;} char get_sex(){return sex;} void display()
2015-04-27 21:32:39
435
原创 课堂题目
#include #include #includeclass String{public:String(){p=NULL;}String(const String &);String(char *str); ~String();String & operator=(const String &);String operator+(const String &);fr
2015-04-27 21:32:37
263
原创 P153 6
#include using namespace std; class Complex {public: Complex(){real=0;imag=0;} Complex(double r){real=r;imag=0;} Complex(double r,double i){real=r;imag=i;} operator double(){return real;}
2015-04-27 21:31:50
611
原创 P153 5
#include //using namespace std; class Matrix {public: Matrix(); friend Matrix operator+(Matrix &,Matrix &); friend ostream& operator<<(ostream&,Matrix&); friend istream& operator>>(istream&,
2015-04-27 21:30:57
325
原创 P153 4
#include class Matrix {public: Matrix(); friend Matrix operator+(Matrix &,Matrix &); void input(); void display(); private: int mat[2][3];
2015-04-27 21:30:15
271
原创 P153 3
#include //用VC++时改为∶#include using namespace std; //用VC++时为取消此行class Complex {public: Complex(){real=0;imag=0;} Complex(double r,double i){real=r;imag=i;} Complex operator+(Complex &c2); Co
2015-04-27 21:26:48
351
原创 P153 2
#include using namespace std; class Complex {public: Complex(){real=0;imag=0;} Complex(double r,double i){real=r;imag=i;} Complex operator+(Complex &c2); Complex operator-(Complex &c2); Comp
2015-04-27 21:26:01
262
原创 P153 1
#include using namespace std; class Complex {public: Complex(){real=0;imag=0;} Complex(double r,double i){real=r;imag=i;} double get_real(); double get_imag(); void display(); private: d
2015-04-27 21:25:17
680
原创 P121 12
#include using namespace std; template class Compare {public: Compare(numtype a,numtype b); numtype max(); numtype min(); private: numtype x,y; }; template Compare::Compare(numtype a
2015-04-20 13:49:02
245
原创 P121 11
#include using namespace std; class Time; class Date {public: Date(int,int,int); friend Time; private: int month; int day; int year; }; Date::Date(int m,int d,int y):month(m),day(d),yea
2015-04-20 13:46:15
245
原创 P121 10
#include using namespace std; class Date; class Time {public: Time(int,int,int); friend void display(const Date &,const Time &); private: int hour; int minute; int sec; }; Time::Time(int
2015-04-20 13:41:25
256
原创 P121 9
#include using namespace std; class Product {public: Product(int n,int q,float p):num(n),quantity(q),price(p){}; void total(); static float average(); static void display(); private: int n
2015-04-20 13:37:24
417
原创 P121 8
#include using namespace std; class Student {public: Student(int n,float s):num(n),score(s){} void change(int n,float s) {num=n;score=s;} void display() {cout<<num<<" "<<score<<endl;} private
2015-04-20 13:34:12
657
原创 P120 7
#include using namespace std; class Student {public: Student(int n,float s):num(n),score(s){} void change(int n,float s) {num=n;score=s;} void display() {cout<<num<<" "<<score<<endl;} privat
2015-04-20 13:29:31
359
原创 P120 6
#include using namespace std; class Student {public: Student(int n,float s):num(n),score(s){} void change(int n,float s) {num=n;score=s;} void display(){cout<<num<<" "<<score<<endl;} private:
2015-04-20 13:22:33
562
原创 P120 5
#include using namespace std; class Student {public: Student(int n,float s):num(n),score(s){} int num; float score; }; void main() {Student stud[5]={ Student(101,78.5),Student(102,85.5),
2015-04-20 13:18:06
392
原创 P119 4
#include using namespace std; class Student {public: Student(int n,float s):num(n),score(s){} void display(); private: int num; float score; }; void Student::display() {cout<<num<<" "<<s
2015-04-20 13:13:51
397
原创 P119 3
#include using namespace std; class Date {public: Date(int=1,int=1,int=2005); void display(); private: int month; int day; int year; }; Date::Date(int m,int d,int y):month(m),day(d),year(
2015-04-20 13:02:58
312
原创 P118 2
#include using namespace std; class Date {public: Date(int,int,int); Date(int,int); Date(int); Date(); void display(); private: int month; int day; int year; }; Date::Date(int m,int d
2015-04-20 12:59:03
441
原创 P67 5
//xt2-5-1.cpp(file1.cpp) #include #include "xt2-5.h" int main(){ Array_max arrmax; arrmax.set_value(); arrmax.max_value(); arrmax.show_value(); return 0;}//xt2-5-2.cpp(arraymax.cpp) #in
2015-04-11 12:49:20
409
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人