对一个数进行若干变换直至变成个位数
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; } }
相关文章推荐
- 将输入的一个数进行多少次变换变成个位数
- java--编写一个JFrame,标题为“计算的窗口”,在该窗口中组件的布局是FlowLayout。窗口中添加两个文本区,当我们在一个文本区中输入若干个数时,另一个文本区同时对输入的数进行求和运算并求
- 求出所有满足下列条件的二位数:将此二位数的个位数字与十位数字进行交换,可得到一个新的 数,要求新数与原数之和小于100。
- 特征值和特征向量的几何意义、计算及其性质(一个变换(或者说矩阵)的特征向量就是这样一种向量,它经过这种特定的变换后保持方向不变,只是进行长度上的伸缩而已)
- 设计一个程序,从键盘上输入若干字符串,利用算法库中的查找函数对给定的字符串进行查找,将查找后的结果输出
- 编程将一个二维数组元素变换为逆向存放,即按元素在内存中的物理排列位置,第一个元素变成倒数第一个元素,第二个元素变成倒数第二个元素,依此类推。
- gridView 实现 点击一个图片 进行3D翻转 然后变成另外一个图片
- 随机生成一个n*n的矩阵,进行行列变换
- 输入一个正数,对该数进行四舍五入到个位数的运算。例如,实数12.56经过四舍五入运算,得到结果13;而12.46经过四舍五入运算,得到结果12。
- 分别显示用float和double指数记数法所能表示的最大值和最小值 以一个最高有效位为1的二进制数字开始,用有符号右移操作符对其进行右移,直至所有二进制位都被移除为止,每移一位都要使用Integer
- 【算法题】非负整数的各位相加,直至变成个位数
- java--第十周--任务二 编写一个JFrame,在该窗口中组件的布局是FlowLayout。窗口中添加两个文本区,当我们在一个文本区中输入若干个数时,另一个文本区同时对输入的数进行
- 2.对图像进行平滑(一个简单的变换)
- JavaScript基础 toFixed() 将一个数值转成字符串,并进行四舍五入,保留指定位数的小数
- 尽管是一个CS专业的学生,小B的数学基础很好并对数值计算有着特别的兴趣,喜欢用计算机程序来解决数学问题。现在,她正在玩一个数值变换的游戏。她发现计算机中经常用不同的进制表示同一个数,如十进制数123表达为16进制时只包含两位数7、11(B),用八进制表示时为三位数1、7、3。按不同进制表达时,各个位数的和也不同,如上述例子中十六进制和八进制中各位数的和分别是18和11。
- 编程将一个二维数组元素变换为逆向存放,即按元素在内存中的物理排列位置,第一个元素变成倒数第一个元素,第二个元素变成倒数第二个元素,依此类推。
- 输入一个任意位数的整数进行逆序输出
- 3.java把一个数组int[]array={1,2,3,4,5,6,7}中的元素进行倒置,变成int[]array={7,6,5,4,3,2,1}.
- JAVA--编写一个JFrame,标题为“计算的窗口”,在该窗口中组件的布局是FlowLayout。窗口中添加两个文本区,当我们在一个文本区中输入若干个数时,另一个文本区同时对输入的数进行求和运算并求
- 两个线程对一个变量进行++操作,直至变量值为20