7.6

运算符
代码中,如果有小数参与运算,结果有可能不精确
输入一个三位数,输出个十百三位数
package com.itheima.test;
import class Test1{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
System.out.println(“输入一个三位数”);
int number=sc.nextInt();
//个位:数字%10
//十位:数字/10%10
//百位:数字/100%10
//····
int ge=number%10;
int shi=number/10%10;
int bai=number/100%10;
System.out.printin(ge);
System.out.printin(shi);
System.out.printin(bai);
}
}

posted @ 2025-07-06 21:42  muyuxiaxing  阅读(5)  评论(0)    收藏  举报