第一种是取模运算  

int qian =input/1000; //千位除以1000
int bai = input/100%10;//百位除以100%10
int shi = input%100/10;//十位%100/10
int ge = input%10;//个位直接%10
System.out.println("千位数"+qian+"百位是"+bai+"十位是"+shi+"个位数是"+ge);

第二种是使用char数组进行分割开依次存到数组

//实现数据 的排序 获取各个位数
public static void main(String[] args) {
System.out.println("请输入一个四位数");
//定义变量接受
@SuppressWarnings("resource")
int number = new Scanner(System.in).nextInt();
if(number>999&&number<10000) {
char[] chars = String.valueOf(number).toCharArray();
System.out.println("千位"+chars[0]);
System.out.println("百位"+chars[1]);
System.out.println("十位"+chars[2]);
System.out.println("个位"+chars[3]);
}else {
System.out.println("你输入的不是四位数··系统终止!!请重新输入!!");
}
}

end

最新文章

  1. abrt-hook-ccpp: Saved core dump of pid 12224导致dn挂掉问题
  2. 绘制图形与3D增强技巧(二)----直线图元
  3. struts2 ,web.xml中配置为/*.action,运行报错Invalid &lt;url-pattern&gt; /*.action in filter mapp
  4. collections——高性能容器数据类型
  5. div添加透明边框透明背景css
  6. linux中的strings命令简介2
  7. docker 指定容器名字
  8. HDU 3397 Sequence operation(线段树)
  9. 捣鼓一个Ajax请求管理器
  10. python编码错误
  11. 2017广东工业大学程序设计竞赛决赛-tmk买礼物
  12. 庖丁解牛Linux内核学习笔记(1)--计算机是如何工作的
  13. Windows 安装 Scoop
  14. tomcat报异常Invalid character found in method name. HTTP method names must be tokens
  15. 学习笔记CB011:lucene搜索引擎库、IKAnalyzer中文切词工具、检索服务、查询索引、导流、word2vec
  16. Deepin 15.5上安装 Node.js
  17. [PGM] What is Probabalistic Graphical Models
  18. MySQL Processlist--常见线程状态
  19. greasemonkey修改网页url
  20. TCP协议具体解释(上)

热门文章

  1. Git-GIt检出
  2. JavaScript 计时事件-setInterval()-clearInterval() -setTimeout()-clearTimeout()
  3. git上传自己的代码
  4. error LNK2001: unresolved external symbol __imp___time64
  5. vim中插入递增数
  6. Goole Search Auto Complete
  7. ubuntu16.04中docker安装curl拒绝连接问题
  8. 动态规划--找零钱 coin change
  9. Behavior trees for AI: How they work
  10. vmware安装centos7 安装redis windows7访问redis