请问用VB.NET 来判断水仙花数 希望哪个高手指点一下啊,谢谢

来源:百度知道 编辑:UC知道 时间:2024/06/20 19:09:08
大概要用 FOR NEXT 循环 ,谢谢

Module Module1

Sub Main()
Console.WriteLine("找出100-500水仙花数:")
For i As Integer = 100 To 500
Dim bai As Integer = i \ 100
Dim shi As Integer = (i - bai * 100) \ 10
Dim ge As Integer = i - bai * 100 - shi * 10
If bai ^ 3 + shi ^ 3 + ge ^ 3 = i Then
Console.Write("{0} ", i)
End If
Next

Console.Read()
End Sub

End Module

各种程序的会有一些不同,但是会有共同点
你看看呢
下面还有连接
有其他答案

我给出两种代码:
#include <iostream.h>
void main()
{
int a[100];
int count=0,i,x,y,z;
cout<<"请输入待测数,以0结束。"<<endl;
do
{
cin>>a[count];
}while(a[count++]!=0);
count--;
for(i=0;i<count;i++)
{
x=a[i]%10;
y=a[i]/10%10;
z=a[i]/100;
if (x*x*x+y*y*y+z*z*z==a[