ZKX's LAB

VB “水仙花数”实现代码 计算代码 水仙花数vb流程图

2021-04-27知识0

用VB编写:找出所有的“水仙花数”。 “水仙花数”是指一个三位数,其各位数字的立方和等于该数本身 代码为:using System;using System.Collections.Generic;using System.Text;namespace_{class Program{static void Main(string[]args){Console.WriteLine(\"一重循环判断:\");Console.WriteLine(\"水仙花数有:\");int i,j,k,l;for(i=100;i;i+){j=i/100;k=i%100/10;l=i%10;int n=j*j*j+k*k*k+l*l*l;if(n=i)Console.WriteLine(n);}Console.WriteLine(\"三重循环判断:\");Console.WriteLine(\"水仙花数有:\");int q,w,e,r;for(q=1;q;q++)for(w=0;w;w+)for(e=0;e;e+){int s=q*100+w*10+e;int t=q*q*q+w*w*w+e*e*e;if(s=t)Console.WriteLine(s);}}}}扩展资料:注意事项自定义函数is(number)判断number的各位数字立方和是否等于它本身,如is(121)返回值0,is(153)返回值1。主函数输入两个正整数m和n(m>;=1,n),输出m-n之间的所有满足各位数字和等于它本身的数。Input多组测试数据,每组输入两个正整数m和n(m>;=1,n)。Output输出m-n之间的所有满足各位数字立方和等于它本身的数,空格隔开(最后一个数后无空格)。Sample Input1 10050 20050 500Sample Output1153153 370 371 407includeincludeint is(int number){int s,sum=0;while(number。

VB中判断闰年和判断水仙花数的程序是什么? 【程序1】题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少?1。.

VB编程水仙花数 VB实现水仙花数的程序代码如下:Private Sub Command_Click()For num=100 To 999a=num Mod 10b=num \\ 10 Mod 10c=num \\ 100If a^3+b^3+c^3=num Then Print numNext numEnd 。

#水仙花数vb流程图

随机阅读

qrcode
访问手机版