java 题目:取一个整数 a 从右端开始的 4~7 位。

import java.util.Scanner;

public class Pro2 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in); 
		System.out.println("input the number:");
		int a = 0 ;
		a = in.nextInt();
		a = a/1000;
		int[] b= new int[4];
		for (int i = 0; i < b.length; i++) {
			b[i] = a%10;
			a = (a-b[i])/10;
		}
		for (int i = 0; i < b.length; i++) {
			System.out.printf("第%d位数字为:%d\n",i+4,b[i]);
		}
	}

}
posted @   七色彩虹k  阅读(139)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫
点击右上角即可分享
微信分享提示