#include<iostream>#include<iomanip>#include<string>using namespace std;class person{protected: char name[20]; int birth_year;public: person(char*na,int year) { strcpy(name,na); birth_year=year; } int cal_age(int this_year) { return this_year-birth_year; }};class graduate:virtual public person{...
#include<iostream>#include <string>using namespace std;int shuz(int a[],int length);int main(){ bool quit=false; int i; while(true) { int choice; cout<<"请输入您的选择 :"<<endl; cout<<"1.按数值大小进行排序"<<'\t'<<"2.按字符串大小进行排序"<<'\t'<<"3.quit"<<endl; cin>>choice; s...
#include<iostream>using namespace std;class RatNum //定义一个有理数类RatNum { public: int fz; int fm; public: RatNum(){} //构造函数 ~RatNum(){} //析构函数 RatNum(int z,int m){fz=z;fm=m;cout<<"有理数为:"<<fz<<"/"<<fm<<endl;}//带参数的构造函数的定义,...
#include<iostream>using namespace std;class RatNum //定义一个有理数类RatNum { public: int fz; int fm; public: RatNum(){} //构造函数 ~RatNum(){} //析构函数 RatNum(int z,int m){fz=z;fm=m;cout<<"有理数为:"<<fz<<"/"<<fm<<endl;}//带参数的构造函数的定义,...
#include<iostream>#include <string>using namespace std;int shuz(int a[],int length);int main(){ bool quit=false; int i; while(true) { int choice; cout<<"请输入您的选择 :"<<endl; cout<<"1.按数值大小进行排序"<<'\t'<<"2.按字符串大小进行排序"<<'\t'<<"3.quit"<<endl; cin>>choice; s...
#include<iostream>using namespace std;class RatNum //定义一个有理数类RatNum { private: int fz; int fm; public: RatNum(){} //构造函数 ~RatNum(){} //析构函数 RatNum(int z,int m){fz=z;fm=m;cout<<"有理数为:"<<fz<<"/"<<fm<<endl;}//带参数的构造函数的定义...
自己编的运算程序,嘿嘿,分享一下#include<iostream>#include<ctime>#include<cstdlib>using namespace std;int main(){ int a[2]; int i,j; srand(time(NULL)); while(1) { bool quit=false; cout<<"请输入您的选择:1.+"<<'\t'<<"2.-"<<'\t'<<"3.*"<<'\t'<<"4./"<<'\t'<<"5.quit:"<<endl; int choice; ...
昨天看的道题目,试了下,两个程序,第一个貌似正常,结果输出数组越界,第二个尝试稍微改动,结果程序崩溃....求助....已知 strcpy函数的原型是 char *strcpy (char *strDest,const char *strSrc);其中strDest是目的字符串 strSrc是源字符串,不能调用C++/C的字符串库函数写出strcpy函数???char *strcpy (char *strDest,const char *strSrc)上面是题目#include<iostream>using namespace std;char *strcpy (char *strDe...
#include <iostream>using namespace std;class complex{ public: complex(){cout<<"调用构造函数"<<endl;} complex(int r,int i); complex(complex&c); void set_c(int r,int i); int get_c(); // void add(complex &c1,complex &c2); //使用普通函数实现两个复数的相加; complex...
#include<iostream>using namespace std;class Time{ private: int hours,minutes,seconds; public: Time(void){}; Time(int h,int m,int s); Time(Time &t); ~Time(){cout<<"the end"<<endl;} void settime(); int gettime(); void add(Time&t1,Time&t2);...
1:#include<iostream>using namespace std;int main(){ int i,j,k,n; cout<<"请输入n的值:"; cin>>n; for (i=1;i<=n;i++) { if (i<=n/2) { for (j=1;j<=n/2+1-i;j++) cout<<" "; for (k=1;k<=2*i-1;k++) cout<<"*"; cout<<endl; } else { for (j=1;j<=i-n/2-1;j++) cout<<" "; for (k=1;k<=(2*(n-i...