欢迎来到第壹文秘! | 帮助中心 分享价值,成长自我!
第壹文秘
全部分类
  • 幼儿/小学教育>
  • 中学教育>
  • 高等教育>
  • 研究生考试>
  • 外语学习>
  • 资格/认证考试>
  • 论文>
  • IT计算机>
  • 法律/法学>
  • 建筑/环境>
  • 通信/电子>
  • 医学/心理学>
  • ImageVerifierCode 换一换
    首页 第壹文秘 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

    C语言程序填空练习题(二).docx

    • 资源ID:1022786       资源大小:22.66KB        全文页数:8页
    • 资源格式: DOCX        下载积分:5金币
    快捷下载 游客一键下载
    账号登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    下载资源需要5金币
    邮箱/手机:
    温馨提示:
    快捷下载时,如果您不填写信息,系统将为您自动创建临时账号,适用于临时下载。
    如果您填写信息,用户名和密码都是您填写的【邮箱或者手机号】(系统自动生成),方便查询和重复下载。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    C语言程序填空练习题(二).docx

    将下面的程序补充完整,以完成指定的功能。1 .尼科彻斯定理ThisprogramistoverifyTheoremofNicoqish.Thatisthecubeofanyintegercanberepresentedasthesumofsomecontinueoddnumbers.Forexample,83=512=57+59+61+63+65+67+69+71.include<iostream>usingnamespacestd;intmain()(intn,a,i;while(1)(cout<<"Pleaseinputaintegertoverify(Otoquit):"cin>>n;if(n=O);/(D/输出等差数列,首项为a*a-a+1,公差为2,项数为na=n*n-n+1;cout<<n<<,'*,'<<n<<"*"<<n<<,'="<<n*n*n<<"=,'<<a;for(i=1;i+)/(2)cout<<"+,<</(3)cout<<endl;)returnO;)2 .角谷猜想ThisprogramistoverifyJiaoguGuess.Thatisgivenanynaturalnumber,ifitisaneven,divides2,ifitisanodd,multiple3andadd1,theresultcontinuestobecalculatedanalogously.Aftersometimes,theresultisalways1.#include<iostream>usingnamespacestd;intmain()(intn,a,i,cnt;while(1)(cout<<"Pleaseinputaintegertoverify(Otoquit):"cin>>n;if(n=O)break;/(1)cnt=O;cout<<"Resultsofverification:n"doif(/(2)n=n*3+1;cout<<',StepNo."<<+cnt<<",<<(n-1)3<<"*3+1="<<n<<endl;)else(n=2;cout<<"StepNo."<<+cnt<<"'<<2*n<<72="<<n<<endl;)while();/(3)cout<<endl;)return0;)3 .四方定理ThisprogramistoverifyTheoremofFourSquares.Thatisallnaturalnumberscanberepresentedassumofnomorethan4squaresofthenumbers.e.g.,123=7*7+7*7+4*4+3*3.#include<iostream>usingnamespacestd;intmain()(inti,j,kJ,number;while(1)cout<<"Pleaseinputanumbertoverify(0toquit):"cin>>number;if(number=O);/(1)cout<<"Resultsofverification:n"for(i=1;i<=number/2;i+)for0=O;j<=i;j+)for(k=0;k<=j;k+)for(l=0;l<=k;l+)if()/(2)(cout<<number<<"="<<i<<"*"<<i<<',+"<<j<<"*"<<j<<"+"<<k<<"*,<<k<<"+"<<l<<"*"<<<<endl;gotoexit;)exit:cout<<"n"returnO;)4 .亲密数Thisisaprogramtofindfriendlynumberspair.WhichmeansthesumofintegerA'sallfactors(exceptA)equalstothesumofintegerB'sallfactors(exceptB)<e.g.sumofinteger220'sallfactorsare:1+2+4+5+10+11+20+22+44+55+110=284,andsumofinteger284'sallfactorsare:1+2+4+71+142=220>#include<iostream>usingnamespacestd;intmain()(inta,i,b,n,m;cout<<"Pleaseinputthescaleyouwanttofindn:"cin>>n;cout<<"nTherearefollowingfriendly-numberspairsmallerthan"<<n<<endl;for(a=1;a<n;a+)(for(;i<=a/2;i+)/(1)if(!(a%i)b+=i;for(;i<=b/2;i+)/(2)if(!(b%i)m+=i;if(&&a<b)/(3)cout<<a<<".,'<<b<<"m;)cout<<endl;return0;)5 .自守数Thisprogramwillfindtheautomorphicnumbers.Thedefinationofaautomorphicnumberis:themantissaofanaturalnumber'ssquareequalstoitself.e.g.,52=25,762=5776,93762=87909376.#include<iostream>usingnamespacestd;intmain()(intmul,number,k,kk;for(number=0;number<1OOOOjnumber+)(for(mul=number,k=1;k*=10);/(1)kk=k*10;mul=number*number%kk;if()/(2)cout<<number<<")cout<<endl;return0;)6 .特殊的四位数Thisprogramwillfindthefourfigureswhichhavethecharacteristicasfollows:abcd=(ab+cd)2.e.g.,3025=(30+25)*(30+25).#include<iostream>usingnamespacestd;intmain()intn,a,b;for(n=1000;n<10000;n+)(;/(1);/(2)if(a+b)*(a+b)=n)cout<<n<<"',;)cout<<endl;return0;)7 .求方程COS(X)x=0的根Thisprogramistofindtherealrootoffunctioncos(x)-x=0.include<iostream>include<cmath>usingnamespacestd;intmain()float×0,x1=0.0;while(1)(; /(1); /(2)if(fabs(x-x1)<1e-6)break;)cout<<"Therealrootis,<<x1<<endl;return0;)8 .特殊的3位数ThisprogramistofindthePerfectSquareNumbers.whichhave3digits,and2ofthemarethesame,e.g.100,121,144,225,400,441,484,676,900.include<iostream>#include<cmath>usingnamespacestd;intmain()(inti,n,a,b,c;for(i=10;i<=sqrt(1000);i+)(;/(1)a=n100;/(2)c=n%10;if(a=bHa=cb=c)cout<<n<<"")cout<<endl;return0;)9 .三重回文数ThisprogramistofindthePalindromeNumbers,whosesquareandcubicarealsoPalindromeNumbers.include<iostream>usingnamespacestd;boolisPalindrome(intn)(intx,y=0;x=n;while(x!=0)(;/(1);/(2)returny=n;)intmain()(intm;for(m=11;m<1000;m+)(if(isPalindrome(m)&&isPalindrome(m*m)&&isPalindrome(m*m*m)cout<<m<<""<<m*m<<"M«m*m*m«endl;)returnO;10 .SIXandNINEThisprogramistofindthenumbersofSIXandNINE,whichsatisfytheformulaSIX+SIX+SIX=NINE+NINE,whereS,I,X,N,Estandfordigitsbetween0and9.#include<iostream>usingnamespacestd;intmain()inti,x,a,b,c,d;for(i=668;i<=999;)/(1)(x=3*i2;a=i10%10;b=x100%10;c=x1000;d=x%10010;if()/(2)(cout<<i<<""<<x<<endl;)return0;)或include<iostream>usingnamespacestd;intmain()(ints,i,x,n,e,six,nine;for(s=1;s<10;s+)for(i=0;i<10;i+)for(x=0;x<10;x+)for(n=1;n<10;n+)for(e=0;e<10;e+)(six=;/(3)nine=;/(4)if()/(5)cout<<six<<",<<nine<<endl;)return0;)11 .马克思手稿中的数学题ThisprogramistosolveaninterestingmathquestioninKarlMarx'smanuscript.TheProblemisasfollows:30personsspent50yuaninarestaurant,amonythem,eachmanspent3yuan,eachwomanspent2yuan,andeachchildspent1yuan.Thequestionishowmanymen,womenandchildrenarethere?#include<iostream>usingnamespacestd;intmain()(intx,y,z;cout<<"MentWomentChildren',<<endl;for(x=0;x<=10;x+)(;/(1);/(2)if()

    注意事项

    本文(C语言程序填空练习题(二).docx)为本站会员(p**)主动上传,第壹文秘仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知第壹文秘(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2023 1wenmi网站版权所有

    经营许可证编号:宁ICP备2022001189号-1

    本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。第壹文秘仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知第壹文秘网,我们立即给予删除!

    收起
    展开