欢迎来到天天文库
浏览记录
ID:37673169
大小:79.50 KB
页数:14页
时间:2019-05-28
《C++作业题及答案》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、一、分析程序,写输出结果1.#include#includevoidmain(){intm,k,i;for(m=1;m<=10;m+=2){k=m/3;for(i=2;i<=k;i++)if(m%i)cout<voidfun();voidmain(){inti;for(i=1;i<5;i++)fun();cout<2、<'t';}468103.#includeintfun(intn){if(n==0)return1;return2*fun(n-1);}voidmain(){inta=5;cout<voidmain(){char*cp="word";for(inti=0;i<4;i++)cout<3、ludevoidmain(){intmax;inta[10]={76,55,95,87,85,83,65,90,77,85};int*p=a;max=*p;for(;p<&a[10];p++)if(*p>max)max=*p;cout<<"max="<voidmain(){intn,k=1,s=0,m;f4、or(n=1;n<=100;n++){k=1;s=0;1m=n;while(2m){k*=m%10;s+=m%10;3m/=10;}if(k>s)cout<voidmain(){doubles;inti,n;cout<<"n=";cin>>n;s=0;for(i=1;i5、序列,以输入0为结束。按输入顺序建立一个以head为表头的单向链表。structnode{intdata;node*next;};create(node*head){node*p,*q;p=newnode;cin>>p->data;q=p;while(p->data){if(head==NULL)head=p;elseq->next=p;;q=p;p=newnode;;cin>>p->data;}q->next=NULL;deletep;}}5.以下程序求方程的全部整数解:3x+2y-7z=5(0≤x,y,z≤1006、)#includevoidmain(){intx,y,z;for(x=0;x<=100;x++)for(y=0;y<=100;y++){if((z=3*x+2*y-5)%7)break;z=3*x+2*y-5)/7;//求出z的值if(z<=100&&z>=0)//检查z的范围cout<<"x="<7、stream.h>voidmain(){inti,n;for(i=0;i<5;i++){for(n=0;n<2*i-1;n++){cout<usingnamespacestd;v8、oidprintFactor(inti);voidmain(){intnumA,numB;cout<<"InputTwoNumbers:"<>numA>>numB;for(inti=numA;i<=numB;i++){printFactor(i);}}voidprintFactor(inti){cout<<"FACTORSO
2、<'t';}468103.#includeintfun(intn){if(n==0)return1;return2*fun(n-1);}voidmain(){inta=5;cout<voidmain(){char*cp="word";for(inti=0;i<4;i++)cout<3、ludevoidmain(){intmax;inta[10]={76,55,95,87,85,83,65,90,77,85};int*p=a;max=*p;for(;p<&a[10];p++)if(*p>max)max=*p;cout<<"max="<voidmain(){intn,k=1,s=0,m;f4、or(n=1;n<=100;n++){k=1;s=0;1m=n;while(2m){k*=m%10;s+=m%10;3m/=10;}if(k>s)cout<voidmain(){doubles;inti,n;cout<<"n=";cin>>n;s=0;for(i=1;i5、序列,以输入0为结束。按输入顺序建立一个以head为表头的单向链表。structnode{intdata;node*next;};create(node*head){node*p,*q;p=newnode;cin>>p->data;q=p;while(p->data){if(head==NULL)head=p;elseq->next=p;;q=p;p=newnode;;cin>>p->data;}q->next=NULL;deletep;}}5.以下程序求方程的全部整数解:3x+2y-7z=5(0≤x,y,z≤1006、)#includevoidmain(){intx,y,z;for(x=0;x<=100;x++)for(y=0;y<=100;y++){if((z=3*x+2*y-5)%7)break;z=3*x+2*y-5)/7;//求出z的值if(z<=100&&z>=0)//检查z的范围cout<<"x="<7、stream.h>voidmain(){inti,n;for(i=0;i<5;i++){for(n=0;n<2*i-1;n++){cout<usingnamespacestd;v8、oidprintFactor(inti);voidmain(){intnumA,numB;cout<<"InputTwoNumbers:"<>numA>>numB;for(inti=numA;i<=numB;i++){printFactor(i);}}voidprintFactor(inti){cout<<"FACTORSO
3、ludevoidmain(){intmax;inta[10]={76,55,95,87,85,83,65,90,77,85};int*p=a;max=*p;for(;p<&a[10];p++)if(*p>max)max=*p;cout<<"max="<voidmain(){intn,k=1,s=0,m;f
4、or(n=1;n<=100;n++){k=1;s=0;1m=n;while(2m){k*=m%10;s+=m%10;3m/=10;}if(k>s)cout<voidmain(){doubles;inti,n;cout<<"n=";cin>>n;s=0;for(i=1;i5、序列,以输入0为结束。按输入顺序建立一个以head为表头的单向链表。structnode{intdata;node*next;};create(node*head){node*p,*q;p=newnode;cin>>p->data;q=p;while(p->data){if(head==NULL)head=p;elseq->next=p;;q=p;p=newnode;;cin>>p->data;}q->next=NULL;deletep;}}5.以下程序求方程的全部整数解:3x+2y-7z=5(0≤x,y,z≤1006、)#includevoidmain(){intx,y,z;for(x=0;x<=100;x++)for(y=0;y<=100;y++){if((z=3*x+2*y-5)%7)break;z=3*x+2*y-5)/7;//求出z的值if(z<=100&&z>=0)//检查z的范围cout<<"x="<7、stream.h>voidmain(){inti,n;for(i=0;i<5;i++){for(n=0;n<2*i-1;n++){cout<usingnamespacestd;v8、oidprintFactor(inti);voidmain(){intnumA,numB;cout<<"InputTwoNumbers:"<>numA>>numB;for(inti=numA;i<=numB;i++){printFactor(i);}}voidprintFactor(inti){cout<<"FACTORSO
5、序列,以输入0为结束。按输入顺序建立一个以head为表头的单向链表。structnode{intdata;node*next;};create(node*head){node*p,*q;p=newnode;cin>>p->data;q=p;while(p->data){if(head==NULL)head=p;elseq->next=p;;q=p;p=newnode;;cin>>p->data;}q->next=NULL;deletep;}}5.以下程序求方程的全部整数解:3x+2y-7z=5(0≤x,y,z≤100
6、)#includevoidmain(){intx,y,z;for(x=0;x<=100;x++)for(y=0;y<=100;y++){if((z=3*x+2*y-5)%7)break;z=3*x+2*y-5)/7;//求出z的值if(z<=100&&z>=0)//检查z的范围cout<<"x="<7、stream.h>voidmain(){inti,n;for(i=0;i<5;i++){for(n=0;n<2*i-1;n++){cout<usingnamespacestd;v8、oidprintFactor(inti);voidmain(){intnumA,numB;cout<<"InputTwoNumbers:"<>numA>>numB;for(inti=numA;i<=numB;i++){printFactor(i);}}voidprintFactor(inti){cout<<"FACTORSO
7、stream.h>voidmain(){inti,n;for(i=0;i<5;i++){for(n=0;n<2*i-1;n++){cout<usingnamespacestd;v
8、oidprintFactor(inti);voidmain(){intnumA,numB;cout<<"InputTwoNumbers:"<>numA>>numB;for(inti=numA;i<=numB;i++){printFactor(i);}}voidprintFactor(inti){cout<<"FACTORSO
此文档下载收益归作者所有