- 博客(55)
- 收藏
- 关注
原创 7-6
#include #include using namespace std; //struct staff struct student { int num; char name[10]; //int age; //double pay; double score; }; int main() { student stud[3]={1001,"z",78
2015-06-16 20:54:52 217
原创 7-5
#include #include using namespace std; struct staff { int num; char name[10]; int age; double pay; }; int main() { staff s[7]={1,"z",18,10000,3,"x",18,20000,2,"f",26,20000,4,"m",26,
2015-06-16 20:43:26 531
原创 7-4
#include #include using namespace std; void fun1() { int a[10]; ofstream outfile1("f1.data",ios::out),outfile2("f2.data",ios::out); if(!outfile1) { cerr<<"open error!"<<endl; exit(
2015-06-16 20:26:19 253
原创 7-3
#include #include using namespace std; int main() { for(int i=1;i<8;i++) cout<<setw(20-i)<<setfill(' ')<<" "<<setw(2*i-1)<<setfill('B')<<"B"<<endl; //设置填充字符 return 0; }
2015-06-16 20:23:14 191
原创 7-2
#include using namespace std; int main() { float a[5]; int i; cout<<"input number:"; for(i=0;i<5;i++) cin>>a[i]; cout.setf(ios::fixed); cout.precision(3); for(i=0;i<5;i++) {
2015-06-16 20:18:20 245
原创 7-1
#include #include using namespace std; void area(float a,float b,float c) { double s,area; if(a+b<=c) cerr<<"a+b<=c,error!"<<endl; else if(b+c<=a) cerr<<"b+c<=a,error!"<<endl; else
2015-06-16 20:11:50 246
原创 6-5
#include class Shape{ public: virtual double area()const =0; }; class Circle:public Shape { public: Circle(double r):radius(r){} virtual double area() const { return 3.1415*radius*ra
2015-06-16 19:47:49 305
原创 6-4
#include class Shape{ public: virtual double area()const =0; }; class Circle:public Shape { public: Circle(double r):radius(r){} virtual double area() const { return 3.1415*radius*ra
2015-06-16 19:41:59 279
原创 6-3(3)
#include using namespace std; class Point { public: Point(float a,float b):x(a),y(b){} virtual ~Point(){cout<<"executing Point destructor"<<endl;} private: float x; float y; }; c
2015-06-16 19:34:05 190
原创 6-3(2)
#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 Cir
2015-06-16 19:29:09 247
原创 6-3(1)
#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 Cir
2015-06-16 19:20:03 205
原创 6-1
#include class Point {public: Point(float x=0,float y=0); void setPoint(float,float); float getX() const {return x;} float getY() const {return y;} friend ostream & operator<<(ostream
2015-06-16 19:11:58 213
原创 5-10
#include #include using namespace std; class Teacher{ public: Teacher(int,string,char); void display(); private: int num; string name; char sex; }; Teacher::Teacher(int n,string nam
2015-05-24 15:27:20 220
原创 5-9
#include #include using namespace std; class Teacher{ public: Teacher(string nam,int a,char s,string ti,string ad,string t); void display(); protected: string name; int age; char sex;
2015-05-24 15:18:33 148
原创 5-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-24 15:04:55 181
原创 5-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<<endl; cout<<"b="<<b<<endl;} private: int a;
2015-05-24 14:47:07 188
原创 5-6
#include using namespace std; class A { public: void f1(); protected: void f2(); private: int i; }; class B:public A { public: void f3(); int k; private: int m; }; class C:pr
2015-05-24 14:44:42 163
原创 5-5
#include using namespace std; class A { public: void f1(); int i; protected: void f2(); int j; private: int k; }; class B:public A { public: void f3(); protected: int m; pri
2015-05-24 14:43:35 196
原创 5-4
#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<<"se
2015-05-24 14:29:42 234
原创 5-3
#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<<"se
2015-05-24 14:19:22 275
原创 5-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<<"se
2015-05-24 14:09:28 194
原创 5-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<<"se
2015-05-24 13:53:06 165
原创 4-7
#include using namespace std; #include class Student{ public: Student(int,char[],char,float); int get_num() { return num; } char * get_name() { return name; } char get_sex(
2015-05-23 14:58:35 197
原创 4-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; ima
2015-05-23 14:52:57 168
原创 4-5
#include class Matrix{ public: Matrix(); friend Matrix operator +(Matrix &,Matrix &); friend istream& operator >>(istream &,Matrix &); friend ostream& operator <<(ostream &,Matrix &); pri
2015-05-23 14:48:32 195
原创 4-4
#include class Matrix{ public: Matrix(); friend Matrix operator +(Matrix &,Matrix &); void input(); void display(); private: int mat[2][3]; }; Matrix::Matrix() { for(int i=0;i<2;i++
2015-05-23 14:45:21 192
原创 4-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 &); Comp
2015-05-23 14:07:46 307
原创 4-3
#include class Complex{ public: Complex() { real=0; imag=0; } Complex(double r,double i) { real=r; imag=i; } Complex operator +(Complex &); Complex operator +(int &);
2015-05-23 14:07:33 193
原创 4-1
#include using namespace std; class Complex{ public: Complex() { real=0; imag=0; } Complex(double r,double i) { real=r; imag=i; } double getreal() { return real; }
2015-05-23 13:56:16 147
原创 3-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(nu
2015-04-20 22:18:42 198
原创 3-11
#include using namespace std; class Student { public: Student(int n,float s):num(n),score(s){} //void change(int n,float s) void change(int n,float s)const { num=n; score=s; } /
2015-04-20 22:10:48 171
原创 3-7(5)
#include using namespace std; class Student { public: Student(int n,float s):num(n),score(s){} //void change(int n,float s) void change(int n,float s)const { num=n; score=s; } /
2015-04-20 17:32:22 197
原创 3-10
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; }; T
2015-04-20 17:29:25 151
原创 3-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: i
2015-04-20 17:17:11 194
原创 3-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<<" "<
2015-04-20 16:48:28 166
原创 3-7(4)
#include using namespace std;class Student{public:Student(int n,float s):num(n),score(s){}//void change(int n,float s)void change(int n,float s)const{num=n;score=s;}//void display()void display()const
2015-04-20 16:26:21 183
原创 3-7(3)
#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(){ coutchange(101,80.5); p->display(); return 0;}
2015-04-20 16:23:27 171
原创 3-7(2)
#include using namespace std;class Student{public:Student(int n,float s):num(n),score(s){}//void change(int n,float s)void change(int n,float s)const{num=n; score=s;}//void display()void display()cons
2015-04-20 15:58:33 180
原创 3-7(1)
#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()const{cout<<num<<" "<<score<<endl;}private:int num;flo
2015-04-20 15:47:44 176
原创 3-5
#include using namespace std;class Student{public:Student(int n,int s):num(n),score(s){}int num;int score;};void max(Student *a){ int i,k=0,max_score=a[0].score; for(i=1;imax_score) {max_score=a[i].sc
2015-04-20 15:24:48 183
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人