欢迎来到天天文库
浏览记录
ID:14630360
大小:75.50 KB
页数:14页
时间:2018-07-29
《华工高级语言程序设计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、}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、m.h>voidmain(){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;for(n=1;n<=100;n++)4、{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、d为表头的单向链表。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)#includevoidmain(6、){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="<voidmain(){inti,n;for(i=0;i7、<5;i++){for(n=0;n<2*i-1;n++){cout<usingnamespacestd;voidprintFactor(inti);voidmain(){intnumA,nu8、mB;cout<<"InputTwoNumbers:"<>numA>>numB;for(inti=numA;i<=numB;i++){printFactor(i);}}voidprintFactor(inti){cout<<"FACTORSO
2、}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、m.h>voidmain(){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;for(n=1;n<=100;n++)4、{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、d为表头的单向链表。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)#includevoidmain(6、){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="<voidmain(){inti,n;for(i=0;i7、<5;i++){for(n=0;n<2*i-1;n++){cout<usingnamespacestd;voidprintFactor(inti);voidmain(){intnumA,nu8、mB;cout<<"InputTwoNumbers:"<>numA>>numB;for(inti=numA;i<=numB;i++){printFactor(i);}}voidprintFactor(inti){cout<<"FACTORSO
3、m.h>voidmain(){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;for(n=1;n<=100;n++)
4、{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、d为表头的单向链表。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)#includevoidmain(6、){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="<voidmain(){inti,n;for(i=0;i7、<5;i++){for(n=0;n<2*i-1;n++){cout<usingnamespacestd;voidprintFactor(inti);voidmain(){intnumA,nu8、mB;cout<<"InputTwoNumbers:"<>numA>>numB;for(inti=numA;i<=numB;i++){printFactor(i);}}voidprintFactor(inti){cout<<"FACTORSO
5、d为表头的单向链表。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)#includevoidmain(
6、){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="<voidmain(){inti,n;for(i=0;i
7、<5;i++){for(n=0;n<2*i-1;n++){cout<usingnamespacestd;voidprintFactor(inti);voidmain(){intnumA,nu
8、mB;cout<<"InputTwoNumbers:"<>numA>>numB;for(inti=numA;i<=numB;i++){printFactor(i);}}voidprintFactor(inti){cout<<"FACTORSO
此文档下载收益归作者所有