求编一个c语言程序,判断幸运数

求编一个c语言程序,判断幸运数,第1张

#include "stdio.h"

int main(int argc,char *argv[]){

int n,i,j

printf("Please enter a positive integer...\n")

scanf("%d",&n)

for(i=n,j=0i(j*=10)+=i%10,i/=10)

printf(j==n ? "Yes\n" : "No\n")

return 0

}

运行样例:

Private Function isxys(a) As Boolean

If a <1000 Or a >9999 Then

isxys = False

Else

t1 = Int(a / 1000) '取千位数

t2 = Int((a - t1 * 1000) / 100)

t3 = Int((a - t1 * 1000 - t2 * 100) / 10)

t4 = a - t1 * 1000 - t2 * 100 - t3 * 10

If t1 + t2 = t3 + t4 Then

isxys = True

Else

isxys = False

End If

End If

End Function

Private Sub Command1_Click()

s = 0

For i = Val(Text1.Text) To Val(Text2.Text)

If isxys(i) Then

List1.AddItem i

s = s + 1

End If

Next

Text3.Text = s

End Sub

Private Sub Command2_Click()

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

List1.Clear

Text1.SetFocus

End Sub

vb6.0代码


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/7867633.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-10
下一篇 2023-04-10

发表评论

登录后才能评论

评论列表(0条)

保存