2个回答
展开全部
不知道你要用什么语言实现。那就用C吧
#include <stdio.h>
int main()
{
int NUM = 21456; //你设定的正整数
int tmp1,tmp2,idx=0;
int result = 1;
tmp1 = NUM;
while(tmp1> 0)
{
tmp2 = tmp1%10;
result = result * tmp2;
tmp1 = (int)(tmp1 /10); //除去最未末位
}
printf("The NUM is %d, and the result is %d\n",NUM,result);
return 0;
}
#include <stdio.h>
int main()
{
int NUM = 21456; //你设定的正整数
int tmp1,tmp2,idx=0;
int result = 1;
tmp1 = NUM;
while(tmp1> 0)
{
tmp2 = tmp1%10;
result = result * tmp2;
tmp1 = (int)(tmp1 /10); //除去最未末位
}
printf("The NUM is %d, and the result is %d\n",NUM,result);
return 0;
}
展开全部
你不说清楚用什么语言实现等于没说啊!
就用vb6吧,vb.net 和c#是一样的
dim s as string
s="5687453"
dim length as integer
length=len(s)
dim i as integer
dim tol as integer
for i=1 to length
tol=tol + cint(mid(s,i,1))
next i
print cstr(tol)
结贴吧
就用vb6吧,vb.net 和c#是一样的
dim s as string
s="5687453"
dim length as integer
length=len(s)
dim i as integer
dim tol as integer
for i=1 to length
tol=tol + cint(mid(s,i,1))
next i
print cstr(tol)
结贴吧
追问
用C语言就行,谢了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询