public class Nan { /** * @param args */ public static void main(String[] args){ Scanner sc=new Scanner(System.in); System.out.println("请输入数字0-9"); int num=sc.nextInt(); System.out.println("请输入位数"); int n=sc.nextInt(); int cup=0; int desk=0; int chair=num; if(num<0||num>9||n<0){ System.out.print("输入错误"); } else for(int i=1;i<n;i++){ chair=chair*10+num; cup=cup+chair; }desk=cup+num; System.out.println(desk); } }