欢迎来到天天文库
浏览记录
ID:55632908
大小:47.50 KB
页数:14页
时间:2020-05-21
《《高级语言程序设计C++》平时作业.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
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、eintfun(intn){if(n==0)return1;return2*fun(n-1);}voidmain(){inta=5;cout<voidmain(){char*cp="word";for(inti=0;i<4;i++)cout<voidmain(){intmax;inta[10]3、={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++){k=1;s=0;1m=n;while(2m){k*=m%10;s+=m%10;3m/=14、0;}if(k>s)cout<voidmain(){doubles;inti,n;cout<<"n=";cin>>n;s=0;for(i=1;i5、ode*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(){intx,y,z;for(x=0;x<=100;x++)for(y=0;y<=100;y++){if((z=3*x+2*y-5)%7)break;6、z=3*x+2*y-5)/7;//求出z的值if(z<=100&&z>=0)//检查z的范围cout<<"x="<voidmain(){inti,n;for(i=0;i<5;i++){for(n=0;n<2*i-1;n++){cout<7、除1和本身)。每行输出数据不超过10个。例如,若输入a为6,b为8,则输出格式要求如下:thefactorsof6:23thefactorsof7:nofactorthefactorsof8:24#includeusingnamespacestd;voidprintFactor(inti);voidmain(){intnumA,numB;cout<<"InputTwoNumbers:"<>numA>>numB;for(inti=numA;i<=numB;i++){printFactor(i);}}voidprintFa8、ctor(inti){cout<<"FACTORSO
2、eintfun(intn){if(n==0)return1;return2*fun(n-1);}voidmain(){inta=5;cout<voidmain(){char*cp="word";for(inti=0;i<4;i++)cout<voidmain(){intmax;inta[10]
3、={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++){k=1;s=0;1m=n;while(2m){k*=m%10;s+=m%10;3m/=1
4、0;}if(k>s)cout<voidmain(){doubles;inti,n;cout<<"n=";cin>>n;s=0;for(i=1;i5、ode*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(){intx,y,z;for(x=0;x<=100;x++)for(y=0;y<=100;y++){if((z=3*x+2*y-5)%7)break;6、z=3*x+2*y-5)/7;//求出z的值if(z<=100&&z>=0)//检查z的范围cout<<"x="<voidmain(){inti,n;for(i=0;i<5;i++){for(n=0;n<2*i-1;n++){cout<7、除1和本身)。每行输出数据不超过10个。例如,若输入a为6,b为8,则输出格式要求如下:thefactorsof6:23thefactorsof7:nofactorthefactorsof8:24#includeusingnamespacestd;voidprintFactor(inti);voidmain(){intnumA,numB;cout<<"InputTwoNumbers:"<>numA>>numB;for(inti=numA;i<=numB;i++){printFactor(i);}}voidprintFa8、ctor(inti){cout<<"FACTORSO
5、ode*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(){intx,y,z;for(x=0;x<=100;x++)for(y=0;y<=100;y++){if((z=3*x+2*y-5)%7)break;
6、z=3*x+2*y-5)/7;//求出z的值if(z<=100&&z>=0)//检查z的范围cout<<"x="<voidmain(){inti,n;for(i=0;i<5;i++){for(n=0;n<2*i-1;n++){cout<7、除1和本身)。每行输出数据不超过10个。例如,若输入a为6,b为8,则输出格式要求如下:thefactorsof6:23thefactorsof7:nofactorthefactorsof8:24#includeusingnamespacestd;voidprintFactor(inti);voidmain(){intnumA,numB;cout<<"InputTwoNumbers:"<>numA>>numB;for(inti=numA;i<=numB;i++){printFactor(i);}}voidprintFa8、ctor(inti){cout<<"FACTORSO
7、除1和本身)。每行输出数据不超过10个。例如,若输入a为6,b为8,则输出格式要求如下:thefactorsof6:23thefactorsof7:nofactorthefactorsof8:24#includeusingnamespacestd;voidprintFactor(inti);voidmain(){intnumA,numB;cout<<"InputTwoNumbers:"<>numA>>numB;for(inti=numA;i<=numB;i++){printFactor(i);}}voidprintFa
8、ctor(inti){cout<<"FACTORSO
此文档下载收益归作者所有