欢迎来到天天文库
浏览记录
ID:18794661
大小:99.50 KB
页数:64页
时间:2018-09-23
《c++编程题目算法大全》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、曾经在软通动力写过的算法题其中有一小部分是参考网上的资料,现在拿出来给大家分享!第3章控制语句/*1、打印出所有的“水仙花数”。所谓“水仙花数”是指一个三位数,其各位数字立方和等于该数本身。例如,153是一水仙花数,因为153=13+53+33。*/#includevoidmain(){inti,a=0,b=0,c=0;for(i=100;i<1000;i++){a=i%10;b=i/10%10;c=i/100%10;if(a*a*a+b*b*b+c*c*c==i)cout<<"i="<2、的因子之和,这个数就称为“完数”。例如,6的因子为1、2、3,而6=1+2+3,因此6是“完数”。编程序找出1000之内的所有完数,并按下面的格式输出其因子:6-〉1,2,3*/#includevoidmain(){inti,j,sum=0,a[50],k,t;for(i=1;i<=1000;i++){sum=0;for(j=1;j";good,noloosening.6.5.2DCSsidewiringtoc3、ompletetheenclosureandtheothersideafterthewiringiscompleted,DCSwithintheenclosurewhenthepowermoduleshouldbeloosenedorthepowergoesout.6.6lowvoltagecableterminalmaking6.6.1firstfor(k=0;k4、+22+222+…+22222(此时n=5),n由键盘输入。*/#includevoidmain(){doublea,sn=0.0,sum=0.0;intn,i;cout<<"pleaseinputanumber";cin>>a; cout<<"pleaseinputnnumber";cin>>n;sn=a;sum=a; for(i=2;i<=n;i++) {sum=sum*10+a;sn+=sum; }cout<<"Sn="<5、。求它在第10次落地时,共经过了多少米?第10次反弹多高?*/#includevoidmain(){doubleh1=100,h2=100,sum=0.0;inti;for(i=1;i<=10;i++){sum+=h2;h1=h1/2.0;good,noloosening.6.5.2DCSsidewiringtocompletetheenclosureandtheothersideafterthewiringiscompleted,DCSwithintheenclosurewhenthepowermoduleshouldbeloosen6、edorthepowergoesout.6.6lowvoltagecableterminalmaking6.6.1firsth2=h1*2;}cout<<"sum="<voidmain(){intnumber,i;num7、ber=1;for(i=10;i>1;i--)number=(number+1)*2;cout<<"number="<voidmain(){ inta; cout<<"请输入a的值:"; cin>>a; cout<<"a的值为:"<8、voidmai
2、的因子之和,这个数就称为“完数”。例如,6的因子为1、2、3,而6=1+2+3,因此6是“完数”。编程序找出1000之内的所有完数,并按下面的格式输出其因子:6-〉1,2,3*/#includevoidmain(){inti,j,sum=0,a[50],k,t;for(i=1;i<=1000;i++){sum=0;for(j=1;j";good,noloosening.6.5.2DCSsidewiringtoc
3、ompletetheenclosureandtheothersideafterthewiringiscompleted,DCSwithintheenclosurewhenthepowermoduleshouldbeloosenedorthepowergoesout.6.6lowvoltagecableterminalmaking6.6.1firstfor(k=0;k4、+22+222+…+22222(此时n=5),n由键盘输入。*/#includevoidmain(){doublea,sn=0.0,sum=0.0;intn,i;cout<<"pleaseinputanumber";cin>>a; cout<<"pleaseinputnnumber";cin>>n;sn=a;sum=a; for(i=2;i<=n;i++) {sum=sum*10+a;sn+=sum; }cout<<"Sn="<5、。求它在第10次落地时,共经过了多少米?第10次反弹多高?*/#includevoidmain(){doubleh1=100,h2=100,sum=0.0;inti;for(i=1;i<=10;i++){sum+=h2;h1=h1/2.0;good,noloosening.6.5.2DCSsidewiringtocompletetheenclosureandtheothersideafterthewiringiscompleted,DCSwithintheenclosurewhenthepowermoduleshouldbeloosen6、edorthepowergoesout.6.6lowvoltagecableterminalmaking6.6.1firsth2=h1*2;}cout<<"sum="<voidmain(){intnumber,i;num7、ber=1;for(i=10;i>1;i--)number=(number+1)*2;cout<<"number="<voidmain(){ inta; cout<<"请输入a的值:"; cin>>a; cout<<"a的值为:"<8、voidmai
4、+22+222+…+22222(此时n=5),n由键盘输入。*/#includevoidmain(){doublea,sn=0.0,sum=0.0;intn,i;cout<<"pleaseinputanumber";cin>>a; cout<<"pleaseinputnnumber";cin>>n;sn=a;sum=a; for(i=2;i<=n;i++) {sum=sum*10+a;sn+=sum; }cout<<"Sn="<5、。求它在第10次落地时,共经过了多少米?第10次反弹多高?*/#includevoidmain(){doubleh1=100,h2=100,sum=0.0;inti;for(i=1;i<=10;i++){sum+=h2;h1=h1/2.0;good,noloosening.6.5.2DCSsidewiringtocompletetheenclosureandtheothersideafterthewiringiscompleted,DCSwithintheenclosurewhenthepowermoduleshouldbeloosen6、edorthepowergoesout.6.6lowvoltagecableterminalmaking6.6.1firsth2=h1*2;}cout<<"sum="<voidmain(){intnumber,i;num7、ber=1;for(i=10;i>1;i--)number=(number+1)*2;cout<<"number="<voidmain(){ inta; cout<<"请输入a的值:"; cin>>a; cout<<"a的值为:"<8、voidmai
5、。求它在第10次落地时,共经过了多少米?第10次反弹多高?*/#includevoidmain(){doubleh1=100,h2=100,sum=0.0;inti;for(i=1;i<=10;i++){sum+=h2;h1=h1/2.0;good,noloosening.6.5.2DCSsidewiringtocompletetheenclosureandtheothersideafterthewiringiscompleted,DCSwithintheenclosurewhenthepowermoduleshouldbeloosen
6、edorthepowergoesout.6.6lowvoltagecableterminalmaking6.6.1firsth2=h1*2;}cout<<"sum="<voidmain(){intnumber,i;num
7、ber=1;for(i=10;i>1;i--)number=(number+1)*2;cout<<"number="<voidmain(){ inta; cout<<"请输入a的值:"; cin>>a; cout<<"a的值为:"<8、voidmai
8、voidmai
此文档下载收益归作者所有