Package COM. hanqi; import Java. util. *; public class yonghukongzhi {public static void main (string [] ARGs) {// todo automatically generated method stub system. out. println ("enter a number:"); required jishu = new partition (system. in); int A = jishu. nextint (); system. out. println ("Enter the number:"); export Geshu = new partition (system. in); int B = Geshu. nextint (); int sum = 0; string c = ""; for (Int J = 0; j <B; j ++) {// A is converted to string type C = C + String. valueof (a); // displays the ascending variation of the base number system. out. println (c); // convert string type back to int type and sum = sum + new INTEGER (c);} system. out. print ("Calculation Result:" + sum );}}
S = a + AA + AAA + AAAA + AA... A, where A is a number. For example, 2 + 22 + 222 + 2222 + 22222 (a total of 5 numbers are added at this time), and the addition of several numbers is controlled by the user.