1 2 3 4 5 6 7 8 |
public static void main(String[] args){ int s=1831; int g = s%10; int sw = s/10%10; int b = s/100%10; int q = s/1000%10; System.out.println("个位数是:"+g+";十位数是:"+sw+";百位数是:"+b+";千位数是:"+q); }//结果:个位数是:1;十位数是:3;百位数是:8;千位数是:1 |
取十位位直接先除10在对10取余
取百位位直接先除100在对10取余
取千位位直接先除1000在对10取余
......后面以此类推
Comments | NOTHING