码迷,mamicode.com
首页 > 编程语言 > 详细

算法训练——阿尔法乘积

时间:2020-01-26 23:57:30      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:long   int   cpp   main   can   bsp   print   算法   return   

 

 

//阿尔法乘积
#include<stdio.h>
int alpha(long long int x){
	if(x<10)
		return x;
	else{
		long n = 1;
		while(x){
			if(x%10 != 0){
				n *= x%10;
				x /= 10; 
			}
			else
				x /= 10; 
		} 
		return alpha(n);
	} 
}
int main(){
	long long int x;
	scanf("%ld",&x);
	printf("%d",alpha(x));
	return 0;
} 

  

算法训练——阿尔法乘积

标签:long   int   cpp   main   can   bsp   print   算法   return   

原文地址:https://www.cnblogs.com/Hqx-curiosity/p/12235001.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!