程序设计:求一个三位数各位数的立方和等于这个数的倒数第二大的数
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/10/02 23:58:18
程序设计:求一个三位数各位数的立方和等于这个数的倒数第二大的数
"#include<stdio.h>intmain(){inta,b,c;intct=0;for(a=9;a>0;a--)for(b=9;b>0;b--)for(c=9;c>0;c--){if(a*100+b*10+c==a*a*a+b*b*b+c*c*c){ct++;if(ct==2)//倒数第二大的数{printf(""%d=%d^3+%d^3+%d^3\n"",a*100+b*10+c,a,b,c);return0;}}}return0;}■■:是不是错啦,运行不了,程序语言有问题补充:上面是C的,当然在VFP下不能运行(且上面要改>=0)
以下是VFP的
set echo off
clear
clear all
ct=0
for a=9 to 0 step -1
for b=9 to 0 step -1
for c=9 to 0 step -1
if a*100+b*10+c=a^3+b^3+c^3 then
ct=ct+1
if ct=2 then
? str(a*100+b*10+c)+""=""+str(a)+""^3""+str(b)+""^3""+str(c)+""^3""
return
endif
endif
endf
endf
endf补充:改上面的?部分为
? str(a*100+b*10+c)+""=""+allt(str(a))+""^3+""+allt(str(b))+""^3+""+allt(str(c))+""^3""
就完美了
结果
371=3^3+7^3+1^3"
以下是VFP的
set echo off
clear
clear all
ct=0
for a=9 to 0 step -1
for b=9 to 0 step -1
for c=9 to 0 step -1
if a*100+b*10+c=a^3+b^3+c^3 then
ct=ct+1
if ct=2 then
? str(a*100+b*10+c)+""=""+str(a)+""^3""+str(b)+""^3""+str(c)+""^3""
return
endif
endif
endf
endf
endf补充:改上面的?部分为
? str(a*100+b*10+c)+""=""+allt(str(a))+""^3+""+allt(str(b))+""^3+""+allt(str(c))+""^3""
就完美了
结果
371=3^3+7^3+1^3"
程序设计:求一个三位数各位数的立方和等于这个数的倒数第二大的数
程序设计题 找出所有的“水仙花数”,所谓“水仙花数”是指一个三位数,其各位数字立方和等于该数本身.例
用java求1000之内所有的 “水仙花数 “,所谓 “水仙花数 “是指一个三位数,其各位数字立方和等于该数本身
100到999间,三位数的各位数的立方和等于这个三位数,用C#语言怎么编写代码
除以一个数,等于求这个数的倒数.
打印输出所有水仙花数.(一个三位数,其各位数字的立方和等于该数本身).
1) 编程实现,输出100-999之间所有的“水仙花数”.“水仙花数”是一个三位数,其各位数的立方和等于该数
有一个三位数,它的十位数比个位数大2,百位数比各位数小2,三位数的和的17倍等于原数,这个三位数是多少?
一个3位数,百位数比十位数大1,个位数是十位数的3倍少2,而这个数加它倒数和等于1171 ,求这个三位数?
一个数的75%等于2.5与2.5的倒数的和,求这个数.
打印出所有的“水仙花数”,所谓“水仙花数”是指一个三位数,其各位数字的立方和等于该数本身.
用VF编程:输出所有的"水仙花数"."水仙花数"是指一个三位数,其各位数字的立方和等于该数本身,如153