完面向对象程序设计期末综合练习四运行结果.docx
《完面向对象程序设计期末综合练习四运行结果.docx》由会员分享,可在线阅读,更多相关《完面向对象程序设计期末综合练习四运行结果.docx(32页珍藏版)》请在冰豆网上搜索。
完面向对象程序设计期末综合练习四运行结果
面向对象程序设计期末综合练习四(运行结果)
写出程序运行结果
1.#include
#include
voidmain()
{
inta[8]={25,48,32,85,64,18,48,29};
intmax,min;
max=min=a[0];
for(inti=0;i<8;i++){
if(x>a[i])max=a[i];
if(x}cout<<"max:"<cout<<"min:"<}2.#includevoidmain(){inta,b;for(a=1,b=2;b<50;){cout<a=a+b;b=a+b;}cout<cout<}3.#includeconstintM=3,N=4;voidmain(){inti,j,s=0;for(i=1;i<=M;i++)for(j=1;j<=N;j++)s+=i*j;cout<<”s=”<}4.#includevoidmain(){inta=2,b=5,c=0;if(a+b>10)c=a*b;elsec=3*a+b;if(c<=20)cout<cout<a=a+b;b=a+b;c+=a+b;cout<<"a,b,c="<}5.#includevoidmain(){intx=5;switch(2*x-3){case4:cout<case7:cout<<2*x+1<<’’;case10:cout<<3*x-1<<’’;break;default:cout<<"default"<}cout<<"switchend."<}6.#include#includeinta[4]={36,-5,73,8};voidmain(){inti,y;for(i=0;i<4;i++){if(a[i]<0)y=1;elseif(a[i]<10)y=a[i]*a[i]+3;elseif(a[i]<60)y=4*a[i]-5;elsey=int(sqrt(a[i]));//sqrt(x)为取x的平方根函数cout<}}7.#includeinta[8]={36,25,20,43,12,70,66,35};voidmain(){ints0,s1,s2;s0=s1=s2=0;for(inti=0;i<8;i++){switch(a[i]%3){case0:s0+=a[i];break;case1:s1+=a[i];break;case2:s2+=a[i];break;}}cout<}8.#includeconstintN=5;voidmain(){inti,p=1,s=0;for(i=1;ip=p*i;s=s+p;cout<cout<}}9.#includeconstintM=20;voidmain(){intc2,c3,c5;c2=c3=c5=0;for(inti=1;i<=M;i++){if(i%2==0)c2++;if(i%3==0)c3++;if(i%5==0)c5++;}cout<}10.#includevoidmain(){inti,j;for(i=0;i<5;i++){for(j=i;j<5;j++)cout<<’*’;cout<}}11.#includevoidmain(){for(inti=1,s=0;i<20;i++){if(i%2==0||i%3==0)continue;cout<s+=i;}cout<}12.#includeconstintT=6;voidmain(){inti,j;for(i=1;i<=T;i+=2)for(j=2;j<=T;j+=2){if(i+jelsecout<<’*’;}}13.#includevoidmain(){inta,b,c=0;for(a=1;a<4;a++)for(b=6;b>1;b-=2){if((a+b)%2==0)c+=a+b;elsec+=a*b;if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
}
cout<<"max:
"<cout<<"min:"<}2.#includevoidmain(){inta,b;for(a=1,b=2;b<50;){cout<a=a+b;b=a+b;}cout<cout<}3.#includeconstintM=3,N=4;voidmain(){inti,j,s=0;for(i=1;i<=M;i++)for(j=1;j<=N;j++)s+=i*j;cout<<”s=”<}4.#includevoidmain(){inta=2,b=5,c=0;if(a+b>10)c=a*b;elsec=3*a+b;if(c<=20)cout<cout<a=a+b;b=a+b;c+=a+b;cout<<"a,b,c="<}5.#includevoidmain(){intx=5;switch(2*x-3){case4:cout<case7:cout<<2*x+1<<’’;case10:cout<<3*x-1<<’’;break;default:cout<<"default"<}cout<<"switchend."<}6.#include#includeinta[4]={36,-5,73,8};voidmain(){inti,y;for(i=0;i<4;i++){if(a[i]<0)y=1;elseif(a[i]<10)y=a[i]*a[i]+3;elseif(a[i]<60)y=4*a[i]-5;elsey=int(sqrt(a[i]));//sqrt(x)为取x的平方根函数cout<}}7.#includeinta[8]={36,25,20,43,12,70,66,35};voidmain(){ints0,s1,s2;s0=s1=s2=0;for(inti=0;i<8;i++){switch(a[i]%3){case0:s0+=a[i];break;case1:s1+=a[i];break;case2:s2+=a[i];break;}}cout<}8.#includeconstintN=5;voidmain(){inti,p=1,s=0;for(i=1;ip=p*i;s=s+p;cout<cout<}}9.#includeconstintM=20;voidmain(){intc2,c3,c5;c2=c3=c5=0;for(inti=1;i<=M;i++){if(i%2==0)c2++;if(i%3==0)c3++;if(i%5==0)c5++;}cout<}10.#includevoidmain(){inti,j;for(i=0;i<5;i++){for(j=i;j<5;j++)cout<<’*’;cout<}}11.#includevoidmain(){for(inti=1,s=0;i<20;i++){if(i%2==0||i%3==0)continue;cout<s+=i;}cout<}12.#includeconstintT=6;voidmain(){inti,j;for(i=1;i<=T;i+=2)for(j=2;j<=T;j+=2){if(i+jelsecout<<’*’;}}13.#includevoidmain(){inta,b,c=0;for(a=1;a<4;a++)for(b=6;b>1;b-=2){if((a+b)%2==0)c+=a+b;elsec+=a*b;if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
cout<<"min:
"<}2.#includevoidmain(){inta,b;for(a=1,b=2;b<50;){cout<a=a+b;b=a+b;}cout<cout<}3.#includeconstintM=3,N=4;voidmain(){inti,j,s=0;for(i=1;i<=M;i++)for(j=1;j<=N;j++)s+=i*j;cout<<”s=”<}4.#includevoidmain(){inta=2,b=5,c=0;if(a+b>10)c=a*b;elsec=3*a+b;if(c<=20)cout<cout<a=a+b;b=a+b;c+=a+b;cout<<"a,b,c="<}5.#includevoidmain(){intx=5;switch(2*x-3){case4:cout<case7:cout<<2*x+1<<’’;case10:cout<<3*x-1<<’’;break;default:cout<<"default"<}cout<<"switchend."<}6.#include#includeinta[4]={36,-5,73,8};voidmain(){inti,y;for(i=0;i<4;i++){if(a[i]<0)y=1;elseif(a[i]<10)y=a[i]*a[i]+3;elseif(a[i]<60)y=4*a[i]-5;elsey=int(sqrt(a[i]));//sqrt(x)为取x的平方根函数cout<}}7.#includeinta[8]={36,25,20,43,12,70,66,35};voidmain(){ints0,s1,s2;s0=s1=s2=0;for(inti=0;i<8;i++){switch(a[i]%3){case0:s0+=a[i];break;case1:s1+=a[i];break;case2:s2+=a[i];break;}}cout<}8.#includeconstintN=5;voidmain(){inti,p=1,s=0;for(i=1;ip=p*i;s=s+p;cout<cout<}}9.#includeconstintM=20;voidmain(){intc2,c3,c5;c2=c3=c5=0;for(inti=1;i<=M;i++){if(i%2==0)c2++;if(i%3==0)c3++;if(i%5==0)c5++;}cout<}10.#includevoidmain(){inti,j;for(i=0;i<5;i++){for(j=i;j<5;j++)cout<<’*’;cout<}}11.#includevoidmain(){for(inti=1,s=0;i<20;i++){if(i%2==0||i%3==0)continue;cout<s+=i;}cout<}12.#includeconstintT=6;voidmain(){inti,j;for(i=1;i<=T;i+=2)for(j=2;j<=T;j+=2){if(i+jelsecout<<’*’;}}13.#includevoidmain(){inta,b,c=0;for(a=1;a<4;a++)for(b=6;b>1;b-=2){if((a+b)%2==0)c+=a+b;elsec+=a*b;if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
2.#include
inta,b;
for(a=1,b=2;b<50;){
cout<a=a+b;b=a+b;}cout<cout<}3.#includeconstintM=3,N=4;voidmain(){inti,j,s=0;for(i=1;i<=M;i++)for(j=1;j<=N;j++)s+=i*j;cout<<”s=”<}4.#includevoidmain(){inta=2,b=5,c=0;if(a+b>10)c=a*b;elsec=3*a+b;if(c<=20)cout<cout<a=a+b;b=a+b;c+=a+b;cout<<"a,b,c="<}5.#includevoidmain(){intx=5;switch(2*x-3){case4:cout<case7:cout<<2*x+1<<’’;case10:cout<<3*x-1<<’’;break;default:cout<<"default"<}cout<<"switchend."<}6.#include#includeinta[4]={36,-5,73,8};voidmain(){inti,y;for(i=0;i<4;i++){if(a[i]<0)y=1;elseif(a[i]<10)y=a[i]*a[i]+3;elseif(a[i]<60)y=4*a[i]-5;elsey=int(sqrt(a[i]));//sqrt(x)为取x的平方根函数cout<}}7.#includeinta[8]={36,25,20,43,12,70,66,35};voidmain(){ints0,s1,s2;s0=s1=s2=0;for(inti=0;i<8;i++){switch(a[i]%3){case0:s0+=a[i];break;case1:s1+=a[i];break;case2:s2+=a[i];break;}}cout<}8.#includeconstintN=5;voidmain(){inti,p=1,s=0;for(i=1;ip=p*i;s=s+p;cout<cout<}}9.#includeconstintM=20;voidmain(){intc2,c3,c5;c2=c3=c5=0;for(inti=1;i<=M;i++){if(i%2==0)c2++;if(i%3==0)c3++;if(i%5==0)c5++;}cout<}10.#includevoidmain(){inti,j;for(i=0;i<5;i++){for(j=i;j<5;j++)cout<<’*’;cout<}}11.#includevoidmain(){for(inti=1,s=0;i<20;i++){if(i%2==0||i%3==0)continue;cout<s+=i;}cout<}12.#includeconstintT=6;voidmain(){inti,j;for(i=1;i<=T;i+=2)for(j=2;j<=T;j+=2){if(i+jelsecout<<’*’;}}13.#includevoidmain(){inta,b,c=0;for(a=1;a<4;a++)for(b=6;b>1;b-=2){if((a+b)%2==0)c+=a+b;elsec+=a*b;if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
a=a+b;
b=a+b;
cout<cout<}3.#includeconstintM=3,N=4;voidmain(){inti,j,s=0;for(i=1;i<=M;i++)for(j=1;j<=N;j++)s+=i*j;cout<<”s=”<}4.#includevoidmain(){inta=2,b=5,c=0;if(a+b>10)c=a*b;elsec=3*a+b;if(c<=20)cout<cout<a=a+b;b=a+b;c+=a+b;cout<<"a,b,c="<}5.#includevoidmain(){intx=5;switch(2*x-3){case4:cout<case7:cout<<2*x+1<<’’;case10:cout<<3*x-1<<’’;break;default:cout<<"default"<}cout<<"switchend."<}6.#include#includeinta[4]={36,-5,73,8};voidmain(){inti,y;for(i=0;i<4;i++){if(a[i]<0)y=1;elseif(a[i]<10)y=a[i]*a[i]+3;elseif(a[i]<60)y=4*a[i]-5;elsey=int(sqrt(a[i]));//sqrt(x)为取x的平方根函数cout<}}7.#includeinta[8]={36,25,20,43,12,70,66,35};voidmain(){ints0,s1,s2;s0=s1=s2=0;for(inti=0;i<8;i++){switch(a[i]%3){case0:s0+=a[i];break;case1:s1+=a[i];break;case2:s2+=a[i];break;}}cout<}8.#includeconstintN=5;voidmain(){inti,p=1,s=0;for(i=1;ip=p*i;s=s+p;cout<cout<}}9.#includeconstintM=20;voidmain(){intc2,c3,c5;c2=c3=c5=0;for(inti=1;i<=M;i++){if(i%2==0)c2++;if(i%3==0)c3++;if(i%5==0)c5++;}cout<}10.#includevoidmain(){inti,j;for(i=0;i<5;i++){for(j=i;j<5;j++)cout<<’*’;cout<}}11.#includevoidmain(){for(inti=1,s=0;i<20;i++){if(i%2==0||i%3==0)continue;cout<s+=i;}cout<}12.#includeconstintT=6;voidmain(){inti,j;for(i=1;i<=T;i+=2)for(j=2;j<=T;j+=2){if(i+jelsecout<<’*’;}}13.#includevoidmain(){inta,b,c=0;for(a=1;a<4;a++)for(b=6;b>1;b-=2){if((a+b)%2==0)c+=a+b;elsec+=a*b;if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
cout<}3.#includeconstintM=3,N=4;voidmain(){inti,j,s=0;for(i=1;i<=M;i++)for(j=1;j<=N;j++)s+=i*j;cout<<”s=”<}4.#includevoidmain(){inta=2,b=5,c=0;if(a+b>10)c=a*b;elsec=3*a+b;if(c<=20)cout<cout<a=a+b;b=a+b;c+=a+b;cout<<"a,b,c="<}5.#includevoidmain(){intx=5;switch(2*x-3){case4:cout<case7:cout<<2*x+1<<’’;case10:cout<<3*x-1<<’’;break;default:cout<<"default"<}cout<<"switchend."<}6.#include#includeinta[4]={36,-5,73,8};voidmain(){inti,y;for(i=0;i<4;i++){if(a[i]<0)y=1;elseif(a[i]<10)y=a[i]*a[i]+3;elseif(a[i]<60)y=4*a[i]-5;elsey=int(sqrt(a[i]));//sqrt(x)为取x的平方根函数cout<}}7.#includeinta[8]={36,25,20,43,12,70,66,35};voidmain(){ints0,s1,s2;s0=s1=s2=0;for(inti=0;i<8;i++){switch(a[i]%3){case0:s0+=a[i];break;case1:s1+=a[i];break;case2:s2+=a[i];break;}}cout<}8.#includeconstintN=5;voidmain(){inti,p=1,s=0;for(i=1;ip=p*i;s=s+p;cout<cout<}}9.#includeconstintM=20;voidmain(){intc2,c3,c5;c2=c3=c5=0;for(inti=1;i<=M;i++){if(i%2==0)c2++;if(i%3==0)c3++;if(i%5==0)c5++;}cout<}10.#includevoidmain(){inti,j;for(i=0;i<5;i++){for(j=i;j<5;j++)cout<<’*’;cout<}}11.#includevoidmain(){for(inti=1,s=0;i<20;i++){if(i%2==0||i%3==0)continue;cout<s+=i;}cout<}12.#includeconstintT=6;voidmain(){inti,j;for(i=1;i<=T;i+=2)for(j=2;j<=T;j+=2){if(i+jelsecout<<’*’;}}13.#includevoidmain(){inta,b,c=0;for(a=1;a<4;a++)for(b=6;b>1;b-=2){if((a+b)%2==0)c+=a+b;elsec+=a*b;if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
3.#include
constintM=3,N=4;
inti,j,s=0;
for(i=1;i<=M;i++)
for(j=1;j<=N;j++)
s+=i*j;
cout<<”s=”<
4.#include
inta=2,b=5,c=0;
if(a+b>10)c=a*b;elsec=3*a+b;
if(c<=20)cout<cout<a=a+b;b=a+b;c+=a+b;cout<<"a,b,c="<}5.#includevoidmain(){intx=5;switch(2*x-3){case4:cout<case7:cout<<2*x+1<<’’;case10:cout<<3*x-1<<’’;break;default:cout<<"default"<}cout<<"switchend."<}6.#include#includeinta[4]={36,-5,73,8};voidmain(){inti,y;for(i=0;i<4;i++){if(a[i]<0)y=1;elseif(a[i]<10)y=a[i]*a[i]+3;elseif(a[i]<60)y=4*a[i]-5;elsey=int(sqrt(a[i]));//sqrt(x)为取x的平方根函数cout<}}7.#includeinta[8]={36,25,20,43,12,70,66,35};voidmain(){ints0,s1,s2;s0=s1=s2=0;for(inti=0;i<8;i++){switch(a[i]%3){case0:s0+=a[i];break;case1:s1+=a[i];break;case2:s2+=a[i];break;}}cout<}8.#includeconstintN=5;voidmain(){inti,p=1,s=0;for(i=1;ip=p*i;s=s+p;cout<cout<}}9.#includeconstintM=20;voidmain(){intc2,c3,c5;c2=c3=c5=0;for(inti=1;i<=M;i++){if(i%2==0)c2++;if(i%3==0)c3++;if(i%5==0)c5++;}cout<}10.#includevoidmain(){inti,j;for(i=0;i<5;i++){for(j=i;j<5;j++)cout<<’*’;cout<}}11.#includevoidmain(){for(inti=1,s=0;i<20;i++){if(i%2==0||i%3==0)continue;cout<s+=i;}cout<}12.#includeconstintT=6;voidmain(){inti,j;for(i=1;i<=T;i+=2)for(j=2;j<=T;j+=2){if(i+jelsecout<<’*’;}}13.#includevoidmain(){inta,b,c=0;for(a=1;a<4;a++)for(b=6;b>1;b-=2){if((a+b)%2==0)c+=a+b;elsec+=a*b;if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
cout<a=a+b;b=a+b;c+=a+b;cout<<"a,b,c="<}5.#includevoidmain(){intx=5;switch(2*x-3){case4:cout<case7:cout<<2*x+1<<’’;case10:cout<<3*x-1<<’’;break;default:cout<<"default"<}cout<<"switchend."<}6.#include#includeinta[4]={36,-5,73,8};voidmain(){inti,y;for(i=0;i<4;i++){if(a[i]<0)y=1;elseif(a[i]<10)y=a[i]*a[i]+3;elseif(a[i]<60)y=4*a[i]-5;elsey=int(sqrt(a[i]));//sqrt(x)为取x的平方根函数cout<}}7.#includeinta[8]={36,25,20,43,12,70,66,35};voidmain(){ints0,s1,s2;s0=s1=s2=0;for(inti=0;i<8;i++){switch(a[i]%3){case0:s0+=a[i];break;case1:s1+=a[i];break;case2:s2+=a[i];break;}}cout<}8.#includeconstintN=5;voidmain(){inti,p=1,s=0;for(i=1;ip=p*i;s=s+p;cout<cout<}}9.#includeconstintM=20;voidmain(){intc2,c3,c5;c2=c3=c5=0;for(inti=1;i<=M;i++){if(i%2==0)c2++;if(i%3==0)c3++;if(i%5==0)c5++;}cout<}10.#includevoidmain(){inti,j;for(i=0;i<5;i++){for(j=i;j<5;j++)cout<<’*’;cout<}}11.#includevoidmain(){for(inti=1,s=0;i<20;i++){if(i%2==0||i%3==0)continue;cout<s+=i;}cout<}12.#includeconstintT=6;voidmain(){inti,j;for(i=1;i<=T;i+=2)for(j=2;j<=T;j+=2){if(i+jelsecout<<’*’;}}13.#includevoidmain(){inta,b,c=0;for(a=1;a<4;a++)for(b=6;b>1;b-=2){if((a+b)%2==0)c+=a+b;elsec+=a*b;if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
a=a+b;b=a+b;c+=a+b;
cout<<"a,b,c="<}5.#includevoidmain(){intx=5;switch(2*x-3){case4:cout<case7:cout<<2*x+1<<’’;case10:cout<<3*x-1<<’’;break;default:cout<<"default"<}cout<<"switchend."<}6.#include#includeinta[4]={36,-5,73,8};voidmain(){inti,y;for(i=0;i<4;i++){if(a[i]<0)y=1;elseif(a[i]<10)y=a[i]*a[i]+3;elseif(a[i]<60)y=4*a[i]-5;elsey=int(sqrt(a[i]));//sqrt(x)为取x的平方根函数cout<}}7.#includeinta[8]={36,25,20,43,12,70,66,35};voidmain(){ints0,s1,s2;s0=s1=s2=0;for(inti=0;i<8;i++){switch(a[i]%3){case0:s0+=a[i];break;case1:s1+=a[i];break;case2:s2+=a[i];break;}}cout<}8.#includeconstintN=5;voidmain(){inti,p=1,s=0;for(i=1;ip=p*i;s=s+p;cout<cout<}}9.#includeconstintM=20;voidmain(){intc2,c3,c5;c2=c3=c5=0;for(inti=1;i<=M;i++){if(i%2==0)c2++;if(i%3==0)c3++;if(i%5==0)c5++;}cout<}10.#includevoidmain(){inti,j;for(i=0;i<5;i++){for(j=i;j<5;j++)cout<<’*’;cout<}}11.#includevoidmain(){for(inti=1,s=0;i<20;i++){if(i%2==0||i%3==0)continue;cout<s+=i;}cout<}12.#includeconstintT=6;voidmain(){inti,j;for(i=1;i<=T;i+=2)for(j=2;j<=T;j+=2){if(i+jelsecout<<’*’;}}13.#includevoidmain(){inta,b,c=0;for(a=1;a<4;a++)for(b=6;b>1;b-=2){if((a+b)%2==0)c+=a+b;elsec+=a*b;if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
5.#include
intx=5;
switch(2*x-3){
case4:
cout<case7:cout<<2*x+1<<’’;case10:cout<<3*x-1<<’’;break;default:cout<<"default"<}cout<<"switchend."<}6.#include#includeinta[4]={36,-5,73,8};voidmain(){inti,y;for(i=0;i<4;i++){if(a[i]<0)y=1;elseif(a[i]<10)y=a[i]*a[i]+3;elseif(a[i]<60)y=4*a[i]-5;elsey=int(sqrt(a[i]));//sqrt(x)为取x的平方根函数cout<}}7.#includeinta[8]={36,25,20,43,12,70,66,35};voidmain(){ints0,s1,s2;s0=s1=s2=0;for(inti=0;i<8;i++){switch(a[i]%3){case0:s0+=a[i];break;case1:s1+=a[i];break;case2:s2+=a[i];break;}}cout<}8.#includeconstintN=5;voidmain(){inti,p=1,s=0;for(i=1;ip=p*i;s=s+p;cout<cout<}}9.#includeconstintM=20;voidmain(){intc2,c3,c5;c2=c3=c5=0;for(inti=1;i<=M;i++){if(i%2==0)c2++;if(i%3==0)c3++;if(i%5==0)c5++;}cout<}10.#includevoidmain(){inti,j;for(i=0;i<5;i++){for(j=i;j<5;j++)cout<<’*’;cout<}}11.#includevoidmain(){for(inti=1,s=0;i<20;i++){if(i%2==0||i%3==0)continue;cout<s+=i;}cout<}12.#includeconstintT=6;voidmain(){inti,j;for(i=1;i<=T;i+=2)for(j=2;j<=T;j+=2){if(i+jelsecout<<’*’;}}13.#includevoidmain(){inta,b,c=0;for(a=1;a<4;a++)for(b=6;b>1;b-=2){if((a+b)%2==0)c+=a+b;elsec+=a*b;if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
case7:
cout<<2*x+1<<’’;
case10:
cout<<3*x-1<<’’;break;
default:
cout<<"default"<}cout<<"switchend."<}6.#include#includeinta[4]={36,-5,73,8};voidmain(){inti,y;for(i=0;i<4;i++){if(a[i]<0)y=1;elseif(a[i]<10)y=a[i]*a[i]+3;elseif(a[i]<60)y=4*a[i]-5;elsey=int(sqrt(a[i]));//sqrt(x)为取x的平方根函数cout<}}7.#includeinta[8]={36,25,20,43,12,70,66,35};voidmain(){ints0,s1,s2;s0=s1=s2=0;for(inti=0;i<8;i++){switch(a[i]%3){case0:s0+=a[i];break;case1:s1+=a[i];break;case2:s2+=a[i];break;}}cout<}8.#includeconstintN=5;voidmain(){inti,p=1,s=0;for(i=1;ip=p*i;s=s+p;cout<cout<}}9.#includeconstintM=20;voidmain(){intc2,c3,c5;c2=c3=c5=0;for(inti=1;i<=M;i++){if(i%2==0)c2++;if(i%3==0)c3++;if(i%5==0)c5++;}cout<}10.#includevoidmain(){inti,j;for(i=0;i<5;i++){for(j=i;j<5;j++)cout<<’*’;cout<}}11.#includevoidmain(){for(inti=1,s=0;i<20;i++){if(i%2==0||i%3==0)continue;cout<s+=i;}cout<}12.#includeconstintT=6;voidmain(){inti,j;for(i=1;i<=T;i+=2)for(j=2;j<=T;j+=2){if(i+jelsecout<<’*’;}}13.#includevoidmain(){inta,b,c=0;for(a=1;a<4;a++)for(b=6;b>1;b-=2){if((a+b)%2==0)c+=a+b;elsec+=a*b;if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
cout<<"switchend."<}6.#include#includeinta[4]={36,-5,73,8};voidmain(){inti,y;for(i=0;i<4;i++){if(a[i]<0)y=1;elseif(a[i]<10)y=a[i]*a[i]+3;elseif(a[i]<60)y=4*a[i]-5;elsey=int(sqrt(a[i]));//sqrt(x)为取x的平方根函数cout<}}7.#includeinta[8]={36,25,20,43,12,70,66,35};voidmain(){ints0,s1,s2;s0=s1=s2=0;for(inti=0;i<8;i++){switch(a[i]%3){case0:s0+=a[i];break;case1:s1+=a[i];break;case2:s2+=a[i];break;}}cout<}8.#includeconstintN=5;voidmain(){inti,p=1,s=0;for(i=1;ip=p*i;s=s+p;cout<cout<}}9.#includeconstintM=20;voidmain(){intc2,c3,c5;c2=c3=c5=0;for(inti=1;i<=M;i++){if(i%2==0)c2++;if(i%3==0)c3++;if(i%5==0)c5++;}cout<}10.#includevoidmain(){inti,j;for(i=0;i<5;i++){for(j=i;j<5;j++)cout<<’*’;cout<}}11.#includevoidmain(){for(inti=1,s=0;i<20;i++){if(i%2==0||i%3==0)continue;cout<s+=i;}cout<}12.#includeconstintT=6;voidmain(){inti,j;for(i=1;i<=T;i+=2)for(j=2;j<=T;j+=2){if(i+jelsecout<<’*’;}}13.#includevoidmain(){inta,b,c=0;for(a=1;a<4;a++)for(b=6;b>1;b-=2){if((a+b)%2==0)c+=a+b;elsec+=a*b;if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
6.#include
inta[4]={36,-5,73,8};
inti,y;
for(i=0;i<4;i++){
if(a[i]<0)y=1;
elseif(a[i]<10)y=a[i]*a[i]+3;
elseif(a[i]<60)y=4*a[i]-5;
elsey=int(sqrt(a[i]));//sqrt(x)为取x的平方根函数
cout<}}7.#includeinta[8]={36,25,20,43,12,70,66,35};voidmain(){ints0,s1,s2;s0=s1=s2=0;for(inti=0;i<8;i++){switch(a[i]%3){case0:s0+=a[i];break;case1:s1+=a[i];break;case2:s2+=a[i];break;}}cout<}8.#includeconstintN=5;voidmain(){inti,p=1,s=0;for(i=1;ip=p*i;s=s+p;cout<cout<}}9.#includeconstintM=20;voidmain(){intc2,c3,c5;c2=c3=c5=0;for(inti=1;i<=M;i++){if(i%2==0)c2++;if(i%3==0)c3++;if(i%5==0)c5++;}cout<}10.#includevoidmain(){inti,j;for(i=0;i<5;i++){for(j=i;j<5;j++)cout<<’*’;cout<}}11.#includevoidmain(){for(inti=1,s=0;i<20;i++){if(i%2==0||i%3==0)continue;cout<s+=i;}cout<}12.#includeconstintT=6;voidmain(){inti,j;for(i=1;i<=T;i+=2)for(j=2;j<=T;j+=2){if(i+jelsecout<<’*’;}}13.#includevoidmain(){inta,b,c=0;for(a=1;a<4;a++)for(b=6;b>1;b-=2){if((a+b)%2==0)c+=a+b;elsec+=a*b;if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
7.#include
inta[8]={36,25,20,43,12,70,66,35};
ints0,s1,s2;
s0=s1=s2=0;
switch(a[i]%3){
case0:
s0+=a[i];break;
case1:
s1+=a[i];break;
case2:
s2+=a[i];break;
cout<}8.#includeconstintN=5;voidmain(){inti,p=1,s=0;for(i=1;ip=p*i;s=s+p;cout<cout<}}9.#includeconstintM=20;voidmain(){intc2,c3,c5;c2=c3=c5=0;for(inti=1;i<=M;i++){if(i%2==0)c2++;if(i%3==0)c3++;if(i%5==0)c5++;}cout<}10.#includevoidmain(){inti,j;for(i=0;i<5;i++){for(j=i;j<5;j++)cout<<’*’;cout<}}11.#includevoidmain(){for(inti=1,s=0;i<20;i++){if(i%2==0||i%3==0)continue;cout<s+=i;}cout<}12.#includeconstintT=6;voidmain(){inti,j;for(i=1;i<=T;i+=2)for(j=2;j<=T;j+=2){if(i+jelsecout<<’*’;}}13.#includevoidmain(){inta,b,c=0;for(a=1;a<4;a++)for(b=6;b>1;b-=2){if((a+b)%2==0)c+=a+b;elsec+=a*b;if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
8.#include
constintN=5;
inti,p=1,s=0;
for(i=1;ip=p*i;s=s+p;cout<cout<}}9.#includeconstintM=20;voidmain(){intc2,c3,c5;c2=c3=c5=0;for(inti=1;i<=M;i++){if(i%2==0)c2++;if(i%3==0)c3++;if(i%5==0)c5++;}cout<}10.#includevoidmain(){inti,j;for(i=0;i<5;i++){for(j=i;j<5;j++)cout<<’*’;cout<}}11.#includevoidmain(){for(inti=1,s=0;i<20;i++){if(i%2==0||i%3==0)continue;cout<s+=i;}cout<}12.#includeconstintT=6;voidmain(){inti,j;for(i=1;i<=T;i+=2)for(j=2;j<=T;j+=2){if(i+jelsecout<<’*’;}}13.#includevoidmain(){inta,b,c=0;for(a=1;a<4;a++)for(b=6;b>1;b-=2){if((a+b)%2==0)c+=a+b;elsec+=a*b;if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
p=p*i;
s=s+p;
cout<cout<}}9.#includeconstintM=20;voidmain(){intc2,c3,c5;c2=c3=c5=0;for(inti=1;i<=M;i++){if(i%2==0)c2++;if(i%3==0)c3++;if(i%5==0)c5++;}cout<}10.#includevoidmain(){inti,j;for(i=0;i<5;i++){for(j=i;j<5;j++)cout<<’*’;cout<}}11.#includevoidmain(){for(inti=1,s=0;i<20;i++){if(i%2==0||i%3==0)continue;cout<s+=i;}cout<}12.#includeconstintT=6;voidmain(){inti,j;for(i=1;i<=T;i+=2)for(j=2;j<=T;j+=2){if(i+jelsecout<<’*’;}}13.#includevoidmain(){inta,b,c=0;for(a=1;a<4;a++)for(b=6;b>1;b-=2){if((a+b)%2==0)c+=a+b;elsec+=a*b;if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
cout<}}9.#includeconstintM=20;voidmain(){intc2,c3,c5;c2=c3=c5=0;for(inti=1;i<=M;i++){if(i%2==0)c2++;if(i%3==0)c3++;if(i%5==0)c5++;}cout<}10.#includevoidmain(){inti,j;for(i=0;i<5;i++){for(j=i;j<5;j++)cout<<’*’;cout<}}11.#includevoidmain(){for(inti=1,s=0;i<20;i++){if(i%2==0||i%3==0)continue;cout<s+=i;}cout<}12.#includeconstintT=6;voidmain(){inti,j;for(i=1;i<=T;i+=2)for(j=2;j<=T;j+=2){if(i+jelsecout<<’*’;}}13.#includevoidmain(){inta,b,c=0;for(a=1;a<4;a++)for(b=6;b>1;b-=2){if((a+b)%2==0)c+=a+b;elsec+=a*b;if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
9.#include
constintM=20;
intc2,c3,c5;
c2=c3=c5=0;
for(inti=1;i<=M;i++){
if(i%2==0)c2++;
if(i%3==0)c3++;
if(i%5==0)c5++;
cout<}10.#includevoidmain(){inti,j;for(i=0;i<5;i++){for(j=i;j<5;j++)cout<<’*’;cout<}}11.#includevoidmain(){for(inti=1,s=0;i<20;i++){if(i%2==0||i%3==0)continue;cout<s+=i;}cout<}12.#includeconstintT=6;voidmain(){inti,j;for(i=1;i<=T;i+=2)for(j=2;j<=T;j+=2){if(i+jelsecout<<’*’;}}13.#includevoidmain(){inta,b,c=0;for(a=1;a<4;a++)for(b=6;b>1;b-=2){if((a+b)%2==0)c+=a+b;elsec+=a*b;if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
10.#include
inti,j;
for(i=0;i<5;i++){
for(j=i;j<5;j++)cout<<’*’;
cout<}}11.#includevoidmain(){for(inti=1,s=0;i<20;i++){if(i%2==0||i%3==0)continue;cout<s+=i;}cout<}12.#includeconstintT=6;voidmain(){inti,j;for(i=1;i<=T;i+=2)for(j=2;j<=T;j+=2){if(i+jelsecout<<’*’;}}13.#includevoidmain(){inta,b,c=0;for(a=1;a<4;a++)for(b=6;b>1;b-=2){if((a+b)%2==0)c+=a+b;elsec+=a*b;if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
11.#include
for(inti=1,s=0;i<20;i++){
if(i%2==0||i%3==0)continue;
cout<
s+=i;
12.#include
constintT=6;
for(i=1;i<=T;i+=2)
for(j=2;j<=T;j+=2){
if(i+jelsecout<<’*’;}}13.#includevoidmain(){inta,b,c=0;for(a=1;a<4;a++)for(b=6;b>1;b-=2){if((a+b)%2==0)c+=a+b;elsec+=a*b;if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
elsecout<<’*’;
13.#include
inta,b,c=0;
for(a=1;a<4;a++)
for(b=6;b>1;b-=2){
if((a+b)%2==0)c+=a+b;elsec+=a*b;
if(b==2)cout<}}14.#includeconstintB=2;voidmain(){intp=1,s=1;while(s<50){p*=B;s+=p;}cout<<"s="<}15.#includevoidmain(){intx=24,y=88;inti=2,p=1;do{while(x%i==0&&y%i==0){p*=i;x/=i;y/=i;}i++;}while(x>=i&&y>=i);cout<}16.#includeconstintN=3;voidmain(){inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};inti,j,c[N][N];for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
14.#include
constintB=2;
intp=1,s=1;
while(s<50){
p*=B;
s+=p;
cout<<"s="<
15.#include
intx=24,y=88;
inti=2,p=1;
do{
while(x%i==0&&y%i==0){
p*=i;
x/=i;
y/=i;
i++;
}while(x>=i&&y>=i);
16.#include
constintN=3;
inta[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}};
intb[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}};
inti,j,c[N][N];
for(i=0;ifor(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
for(j=0;jc[i][j]=a[i][j]+b[i][j];for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
c[i][j]=a[i][j]+b[i][j];
for(i=0;ifor(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
for(j=0;jcout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
cout<cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
cout<}}17.#includeinta=5;voidmain(){intb=a+20;inta=10;cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
17.#include
inta=5;
voidmain(){
intb=a+20;
inta=10;
cout<{inta=0,b=0;for(inti=1;i<6;i++){a+=i;b+=a;}cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
{inta=0,b=0;
for(inti=1;i<6;i++){
a+=i;b+=a;
cout<}cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
cout<}18.#includeintf1(intx,inty){x=x+y;y=x+y;cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
18.#include
intf1(intx,inty)
x=x+y;y=x+y;
cout<<"x="<returnx+y;}voidmain(){intx=5,y=8;intz=f1(x,y);cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
returnx+y;
intx=5,y=8;
intz=f1(x,y);
cout<<"x="<cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
cout<<",z="<}19.#includevoidf2(int&x,int&y){intz=x;x=y;y=z;}voidf3(int*x,int*y){intz=*x;*x=*y;*y=z;}voidmain(){intx=10,y=26;cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
19.#include
voidf2(int&x,int&y)
intz=x;x=y;y=z;
voidf3(int*x,int*y)
intz=*x;*x=*y;*y=z;
intx=10,y=26;
cout<<"x,y="<f2(x,y);cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
f2(x,y);
cout<<"x,y="<f3(&x,&y);cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
f3(&x,&y);
cout<<"x,y="<x++;y--;f2(y,x);cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
x++;y--;
f2(y,x);
cout<<"x,y="<}20.#includevoidf4(inta[],intn,int&s){s=0;for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
20.#include
voidf4(inta[],intn,int&s)
s=0;
for(inti=0;i}voidmain(){intb[8]={4,8,6,9,2,10,7,12};intx;f4(b,5,x);cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
intb[8]={4,8,6,9,2,10,7,12};
intx;f4(b,5,x);
cout<inty;f4(b+3,4,y);cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
inty;f4(b+3,4,y);
cout<cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
cout<}21.#includevoidmain(){inta[8]={36,25,48,14,55,40,50,24};intb1,b2;b1=b2=a[0];for(inti=1;i<8;i++)if(a[i]>b1){b2=b1;b1=a[i];}elseif(a[i]>b2)b2=a[i];cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
21.#include
inta[8]={36,25,48,14,55,40,50,24};
intb1,b2;
b1=b2=a[0];
for(inti=1;i<8;i++)
if(a[i]>b1){b2=b1;b1=a[i];}
elseif(a[i]>b2)b2=a[i];
cout<}22.#includevoidmain(){chara[]="abcdabcabfgacd";inti1=0,i2=0,i=0;while(a[i]){if(a[i]==’a’)i1++;if(a[i]==’b’)i2++;i++;}cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
22.#include
chara[]="abcdabcabfgacd";
inti1=0,i2=0,i=0;
while(a[i]){
if(a[i]==’a’)i1++;
if(a[i]==’b’)i2++;
cout<}23.#includevoidmain(){inta[10]={76,83,54,62,40,75,90,92,77,84};intb[4]={60,70,90,101};intc[4]={0};for(inti=0;i<10;i++){intj=0;while(a[i]>=b[j])j++;c[j]++;}for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
23.#include
inta[10]={76,83,54,62,40,75,90,92,77,84};
intb[4]={60,70,90,101};
intc[4]={0};
for(inti=0;i<10;i++){
intj=0;
while(a[i]>=b[j])j++;
c[j]++;
for(i=0;i<4;i++)cout<cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
cout<}24.#include#includevoidmain(){chara[5][10]={"student","worker","soldier","cadre","peasant"};chars1[10],s2[10];strcpy(s1,a[0]);strcpy(s2,a[0]);for(inti=1;i<5;i++){if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);}cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
24.#include
chara[5][10]={"student","worker","soldier","cadre","peasant"};
chars1[10],s2[10];
strcpy(s1,a[0]);strcpy(s2,a[0]);
for(inti=1;i<5;i++){
if(strcmp(a[i],s1)>0)strcpy(s1,a[i]);
if(strcmp(a[i],s2)<0)strcpy(s2,a[i]);
cout<}25.#includeconstintN=5;voidfun();voidmain(){for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
25.#include
voidfun();
for(inti=1;ifun();}voidfun(){staticinta;intb=2;cout<<(a+=3,a+b)<<'';}26.#includevoidmain(){chars[3][5]={"1234","abcd","+-*/"};char*p[3];for(intI=0;I<3;I++)p[I]=s[I];for(I=2;I>=0;I--)cout<cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
fun();
voidfun()
staticinta;
intb=2;
cout<<(a+=3,a+b)<<'';
26.#include
chars[3][5]={"1234","abcd","+-*/"};
char*p[3];
for(intI=0;I<3;I++)p[I]=s[I];
for(I=2;I>=0;I--)cout<
cout<}27.#includevoidmain(){inti,j,len[3];chara[3][8]={"year","month","day"};for(i=0;i<3;i++){for(j=0;j<8;j++)if(a[i][j]=='\0'){len[i]=j;break;}cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
27.#include
inti,j,len[3];
chara[3][8]={"year","month","day"};
for(i=0;i<3;i++){
for(j=0;j<8;j++)
if(a[i][j]=='\0'){
len[i]=j;break;
cout<"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
"<}}28.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
28.#include
classCD{
char*a;
intb;
public:
voidInit(char*aa,intbb)
a=newchar[strlen(aa)+1];
strcpy(a,aa);
b=bb;
char*Geta(){returna;}
intGetb(){returnb;}
voidOutput(){cout<}dx;voidmain(){CDdy;dx.Init("abcdef",30);dy.Init("shenyafen",3*dx.Getb()+5);dx.Output();dy.Output();}29.#include#includeclassCD{char*a;intb;public:voidInit(char*aa,intbb){a=newchar[strlen(aa)+1];strcpy(a,aa);b=bb;}char*Geta(){returna;}intGetb(){returnb;}voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
}dx;
CDdy;
dx.Init("abcdef",30);
dy.Init("shenyafen",3*dx.Getb()+5);
dx.Output();
dy.Output();
29.#include
voidOutput(){cout<};voidmain(){CDdx,dy;chara[20];dx.Init("abcdef",30);strcpy(a,dx.Geta());strcat(a,"xyz");dy.Init(a,dx.Getb()+20);dx.Output();dy.Output();}30.#includeclassCE{private:inta,b;intgetmax(){return(a>b?a:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMax();};intCE::GetMax(){intd=getmax();return(d>c?d:c);}voidmain(){intx=5,y=12,z=8;CEex,*ep=&ex;ex.SetValue(x,y,z);cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
};
CDdx,dy;
chara[20];
strcpy(a,dx.Geta());
strcat(a,"xyz");
dy.Init(a,dx.Getb()+20);
30.#include
classCE{
private:
intgetmax(){return(a>b?
a:
b);}
intc;
voidSetValue(intx1,intx2,intx3){
a=x1;b=x2;c=x3;
intGetMax();
intCE:
:
GetMax(){
intd=getmax();
return(d>c?
d:
c);
intx=5,y=12,z=8;
CEex,*ep=&ex;
ex.SetValue(x,y,z);
cout<ep->SetValue(x+y,y-z,20);cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
ep->SetValue(x+y,y-z,20);
cout<GetMax()<}31.#includeclassCE{private:inta,b;intgetmin(){return(aa:b);}public:intc;voidSetValue(intx1,intx2,intx3){a=x1;b=x2;c=x3;}intGetMin();};intCE::GetMin(){intd=getmin();return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
31.#include
intgetmin(){return(a
intGetMin();
GetMin(){
intd=getmin();
return(dd:c);}voidmain(){intx=5,y=12,z=8;CE*ep;ep=newCE;ep->SetValue(x+y,y-z,10);cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
CE*ep;
ep=newCE;
ep->SetValue(x+y,y-z,10);
cout<GetMin()<CEa=*ep;cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
CEa=*ep;
cout<}32.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
32.#include
classFranction{//定义分数类
intnume;//定义分子
intdeno;//定义分母
//把*this化简为最简分数,具体定义在另外文件中实现
voidFranSimp();
//返回两个分数*this和x之和,具体定义在另外文件中实现
FranctionFranAdd(constFranction&x);
//置分数的分子和分母分别0和1
voidInitFranction(){nume=0;deno=1;}
//置分数的分子和分母分别n和d
voidInitFranction(intn,intd){nume=n;deno=d;}
//输出一个分数
voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(7,12);b.InitFranction(-3,8);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}33.#includeclassFranction{//定义分数类intnume;//定义分子intdeno;//定义分母public://把*this化简为最简分数,具体定义在另外文件中实现voidFranSimp();//返回两个分数*this和x之和,具体定义在另外文件中实现FranctionFranAdd(constFranction&x);//置分数的分子和分母分别0和1voidInitFranction(){nume=0;deno=1;}//置分数的分子和分母分别n和dvoidInitFranction(intn,intd){nume=n;deno=d;}//输出一个分数voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
Franctiona,b,c,d;
a.InitFranction(7,12);
b.InitFranction(-3,8);
c.InitFranction();
c=a.FranAdd(b);
d=c.FranAdd(a);
cout<<"a:
";a.FranOutput();
cout<<"b:
";b.FranOutput();
cout<<"c:
";c.FranOutput();
cout<<"d:
";d.FranOutput();
33.#include
voidFranOutput(){cout<};voidmain(){Franctiona,b,c,d;a.InitFranction(6,15);b.InitFranction(3,10);c.InitFranction();c=a.FranAdd(b);d=c.FranAdd(a);cout<<"a:";a.FranOutput();cout<<"b:";b.FranOutput();cout<<"c:";c.FranOutput();cout<<"d:";d.FranOutput();}34.#include#includeclassA{char*a;public:A(char*s){a=newchar[strlen(s)+1];strcpy(a,s);cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
a.InitFranction(6,15);
b.InitFranction(3,10);
34.
classA{
A(char*s){
a=newchar[strlen(s)+1];
strcpy(a,s);
cout<}~A(){delete[]a;cout<<"Destructor!"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
~A(){
delete[]a;
cout<<"Destructor!
"<}};voidmain(){Ax("xuxiaokai");A*y=newA("weirong");deletey;}35.#includeclassA{int*a;public:A(intx=0):a(newint(x)){}~A(){deletea;}intgetA(){return*a;}voidsetA(intx){*a=x;}};voidmain(){Ax1,x2(3);A*p=&x2;p->setA(x2.getA()+5);x1.setA(15+x1.getA());cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
Ax("xuxiaokai");
A*y=newA("weirong");
deletey;
35.
int*a;
A(intx=0):
a(newint(x)){}
~A(){deletea;}
intgetA(){return*a;}
voidsetA(intx){*a=x;}
Ax1,x2(3);
A*p=&x2;
p->setA(x2.getA()+5);
x1.setA(15+x1.getA());
cout<}36.#includeclassA{inta;public:A(intaa=0):a(aa){cout<
36.
inta;
A(intaa=0):
a(aa){cout<
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1