public class AddNum {
public static void main(String[] args) {
int a, temp, num, c = 0, sum;
Scanner sc = new Scanner(System.in);
System.out.println("请输入一个数:");
a = sc.nextInt();
System.out.println("请输入位数:");
temp = sc.nextInt();
num = a;
for (int i = 1; i < temp; i++) {
a = a * 10 + num;
c += a;
}
sum = c + num;
System.out.println("sum:" + sum);
}
}作者: LSD-ZWH 时间: 2015-12-12 22:36
没看懂你这个题啥意思,要加到多少?作者: 吴志超 时间: 2015-12-12 22:44
public class Demo_Hello {
public static void main(String[] args) {
int s = 0;
Scanner sc = new Scanner(System.in);
System.out.println("请输入位数");
int a = sc.nextInt();
System.out.println("请输入基数");
int b = sc.nextInt();
for (int i = 1; i <= a; i++) {
for (int j = 0; j < i; j++) {
s += Math.pow(10, j)*b;
}
}
System.out.println(s);
}
}
自己写的,亲测可行,拿去撸 不过没注释作者: lvhongli 时间: 2015-12-14 18:32
慢慢来。。。。。。。。。。。。。作者: 黑夜中那颗星 时间: 2015-12-15 20:04
每次乘10再加2