您的位置:首页 > 其它

对一个数进行若干变换直至变成个位数

2017-05-23 16:28 239 查看
package think;

import java.util.ArrayList;
import java.util.*;
import java.io.*;

public class think{
public static void main(String[] args){
int num;

List<Integer> a = new ArrayList<Integer>();
Scanner sc = new Scanner(System.in);
sf s = new sf();
num = sc.nextInt();

while(num > 10){
num = s.a(num);
}
System.out.println(num);
}
}

class sf{
int y;
int count = 1;

public int a(int x){
count = 1;
while(x > 10){
y = x % 10;
x = x / 10;
count = count * y;
}
count = count * x;

//while(count > 10){
//y = count % 10;
//int i = count / 10;
//count = i * y;
//}

//System.out.println(count);

return count;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐