- 博客(55)
- 收藏
- 关注
原创 7-6
#include #include using namespace std;//struct staffstruct 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
248
原创 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
734
原创 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
296
原创 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
232
原创 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
270
原创 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
301
原创 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
361
原创 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
323
原创 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
228
原创 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
281
原创 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
241
原创 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
262
原创 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
244
原创 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
178
原创 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
210
原创 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
222
原创 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
194
原创 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
227
原创 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
262
原创 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
323
原创 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
225
原创 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
202
原创 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
225
原创 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
203
原创 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
226
原创 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
223
原创 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
349
原创 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
223
原创 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
182
原创 3-12
#include using namespace std;templateclass Compare{ public: Compare(numtype a,numtype b); numtype max(); numtype min(); private: numtype x,y;};templateCompare::Compare(nu
2015-04-20 22:18:42
243
原创 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
203
原创 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
240
原创 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
184
原创 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
234
原创 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
197
原创 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
222
原创 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
198
原创 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
216
原创 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
211
原创 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
222
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅