S=2+22+222+2222.....
大佬帮帮我
import java.util.Scanner;
public class Demo {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
System.out.println("输入整数a:");
int a=in.nextInt();
int sum=0,num=a,n=1;
String str=a+"";
while (n<=num)
{
sum+=a;
a=(a*10)+num;
if (n<num){
str=str+"+"+a;
}
n++;
}
System.out.print("s="+str+"="+sum);
}
}