1. 程式人生 > >Scanner輸入數字時個位十位百位千位單獨取出。

Scanner輸入數字時個位十位百位千位單獨取出。

Scanner inn = new Scanner(System.in);

  int i = inn.nextInt();

  System.out.println("個位是"+i%10+"十位是"+i/10%10+"百位是"+i/100%10+"千位是"+i/1000%10);

 

 

Scanner inn = new Scanner(System.in);


  String s = inn.next();

 

  for (int i=0;i<s.length();i++){

  String str1= s.substring(i,i+1);

  System.out.println(str1);}