本人小白的解法,自我感觉解的还不错哈哈哈,感觉解的不好的见谅....
import java.util.Scanner;
/**
*
*/
@SuppressWarnings({"all"})
public class Main80 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num1 = sc.nextInt();//第一个数
int num2 = sc.nextInt();//第二个数
int n = sc.nextInt();//长度为n
String str = num1 + "" + num2 + "";//用一个字符串变量拼接 num1和num2
int p1 = 0;
int p2 = 1;
while (true) {
if (str.length() < n) {
char[] chars = str.toCharArray(); //把str字符串转为char数组
int j = (chars[p1++] - '0') * (chars[p2++] - '0');//进行运算
str += j;//让str字符串拼接得到的积
} else { //如果 str.length() < n 不成立,就进行打印
char[] chars = str.toCharArray();
for (int i = 0; i < n; i++) {
System.out.print(chars[i]);
if ( i < n - 1) {
System.out.print(" ");
}
}
break;
}
}
}
}