程序设计综合练习题答案_第1页
程序设计综合练习题答案_第2页
程序设计综合练习题答案_第3页
程序设计综合练习题答案_第4页
程序设计综合练习题答案_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、/莫尼数列/只能,找到2的19次方,整形越界#include<iostream.h>#include<math.h>void main()int p; int m=1;int k;int t;int flag=1;cout<<2<<" "<<3<<endl;for(p=3;p<70;p+)for(k=2;k<=p-1;k+) if(p%k=0) goto flag; /cout<<p<<endl; m=pow(2,p);for(t=2;t<m-1;t+)if(m

2、-1)%t=0) goto flag;cout<<p<<" "<<m-1<<endl; flag:; loop:; #include <cstdlib>#include <iostream>using namespace std;int main(int argc, char *argv) int A; int B; int C;int i,m,n; for(i=1;i<100;i+) for(m=1;m<100;m+) for( n=1;n<100;n+) A=i*288; B=m*

3、240; C=n*192; if(A=B) &&(A=C)&&(B=C) cout<<"A"<<i <<"天"<<"B"<<m <<"天"<<"C"<<n <<"天"<<A <<"距离"<<endl;system("PAUSE"); return 0; syste

4、m("PAUSE"); return EXIT_SUCCESS;#include <cstdlib>#include <iostream>using namespace std;/运行环境devc+4.9.9.2 int main(int argc, char *argv) int i; int k; int a11=1,1,1,1,1,1,1,1,1,1,1 ;/数组赋值 a10=1; for(k=10;k>=1;k-) ak-1=2*ak+2; /10天1,9天4,8天10,递推公式。 for(i=1;i<=10;i+)cout<

5、;<ai<<endl; system("PAUSE"); return EXIT_SUCCESS;#include <cstdlib>#include <iostream>using namespace std;int main(int argc, char *argv) int A=1;int B=1;int C=1;int D=1;for(A=1;A<=4;A+)for (B=1;B<=4;B+)for (C=1;C<=4;C+) for (D=1;D<=4;D+) if( (A!=B)&&

6、;(A!=C)&&(A!=D)&&(B!=C)&&(B!=D)&&(C!=D)/ 先要判读这种条件 先筛选 if(A=1)+(B!=4)+(C!=1&&C!=4)+(D=4)=3) cout<<"A马第"<<A<<endl; cout<<"B马第"<<B<<endl; cout<<"C马第"<<C<<endl; cout<<"D

7、马第"<<D<<endl; system("PAUSE"); return EXIT_SUCCESS;#include<iostream.h>int main()int a=1;int b=1;int c=1;int m=1;int d=1; for(a=0;a<=1;a+) for(b=0;b<=1;b+) for(d=0;d<=1;d+) m=a+b+d; if( (m<=2) ) if(a+b!=2) if(a+d!=2) cout<<a<<b<<d<<

8、;endl; if(d=0) cout<<"d不在家 " if(b=0) cout<<"b不在家 " if(a=0) cout<<"a不在家 " cout<<"c永远不可能在家"<<endl; #include <cstdlib>#include <iostream>/ 20 个 默尼数列 using namespace std;int f(int n) int m; if (n=0) return m=3;/n=2 m=5 n=3 m=9 else return 2*f(n-1)-1;int main(int argc, char *argv) int n; cout<<"请输

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论