(1)已知一个三位数,请分别获取该三位数上每一位数值
(2)例如123的个位、十位、百位,分别是321
打印格式"数字的123的个位是3,十位是2,百位是1"

解决方案 »

  1.   

    public class Test {
    public static void main(String[] args) {
    Scanner scn=new Scanner(System.in);
    int a=scn.nextInt();
    System.out.println("数字"+a+"的个位是"+a%10+",十位是"+a/10%10+",百位是"+
    a/100);
    }
    }
      

  2.   

    public class Demo {
         
        public static void main(String[] args) {
         
         Integer num = 234;     System.out.println("百 is:" + num / 100);     System.out.println("十 is:" + num / 10 % 10);     System.out.println("个 is:" + num % 10);
        }
    }
      

  3.   

    为了分我也是拼了public class Test {    private static final String[] arrs = {"个", "十", "百", "千", "万"};    public static void main(String[] args) {
            Integer num = 25616;
            String str = String.valueOf(num);
            char[] chs = str.toCharArray();
            int index = chs.length - 1;
            for(char ch : chs){
                System.out.println(arrs[index] + " 位 是 "+ch);
                --index;
            }
        }
    }
      

  4.   

    我也拼了
    public class Test {    private static final String[] arrs = {"个", "十", "百", "千", "万"};    public static void main(String[] args) {
            Integer num = 25616;
            String str = String.valueOf(num);
            char[] chs = str.toCharArray();
            int index = chs.length - 1;
            for(char ch : chs){
                System.out.println(arrs[index] + " 位 是 "+ch);
                --index;
            }
        }
    }
      

  5.   

    public class demo04 {
    public static void main(String[] args) {
    // TODO Auto-generated method stub
          /**
           * 首先要有一个三位数:可以键盘录用也可以自己输入,既然是新人那就直接赋值吧!*/
    int num=423;//定义一个三位数
    int g=0;//定义个位数
    int s=0;//定义一个十位数上的数
    int b=0;//定义一个百位上的数值
    /*
     * 因为这些数的数据类型都是int整数型的,
     * 所以num除以100是等于4的,
     * 后面不会有小数*/
    b=num/100;
    /*
     * 423/10=42(后面也不会有小数);这个“%”叫余;42%10=4....2,然后得到s=2*/
    s=(num/10)%10;
    /*
     * 个位就更好理解了423%10=42.....4,所以得到g=3了*/
    g=num%10;
    System.out.println("个位数是"+g+"十位数是"+s+"百位数是"+b);

    }}
    每个人都是从小白过来的希望对你有所帮助。加油!
      

  6.   

    public class Demo{
         
        public static void main(String[] args) {
         
         int num = 199;     System.out.println("百位:" + num / 100);     System.out.println("十位:" + num / 10 % 10);     System.out.println("个位:" + num % 10);
        }
    }
      

  7.   

    数字的123的个位是3,十位是2,百位是1
    System.out.println(“数字的"+num +个位是:" +  num % 10+",十位是"+num / 10 % 10+",百位是"+num / 100);
      

  8.   

    首先要知道如何获取个位,十位,百位的值
      以三位数为例:
         个位=值%10
         十位=值/10%10
         百位=值/100
    当然还有一个万金油方法,不管哪位数都能轻松获取.....那就是:
         个位=值%10
         十位=值/10%10
         百位=值/100%10
         千位=值/1000%10....
    以此类推
    代码如下:public class Demo01 {
    public static void main(String[] args) {
    int i = 123;
    int ge = i % 10;
    int shi = i/10%10;
    int bai = i/100;
    System.out.println(i+"的个位是"+ge+",十位是"+shi+",百位是"+bai);
    }
    }
      

  9.   

    import java.util.Scanner;public class Demo {

    public static void main(String[] args) {


    Scanner sc = new Scanner(System.in);

    int nextInt = sc.nextInt();

    int a = nextInt%10;//个位

    int b = nextInt/10%10;//十位

    int c = nextInt/100;//百位

    System.out.println(nextInt+"的个位是:"+a+", 十位是:"+b+",百位是:"+c);
    }
    }
      

  10.   

    需要这么复杂么:
    public static void test02(){
    int num = 123;
    String strNum = String.valueOf(num);
    System.out.println("百位:"+strNum.charAt(0) +" ,十位:"+strNum.charAt(1) +" ,个位:"+strNum.charAt(2));
    }