java入门小程序求解
来源:百度知道 编辑:UC知道 时间:2024/05/18 05:39:18
除10000求模得到第一个数,除1000得到第二个……
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Divide {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = null;
if (null != (line = br.readLine())) {
int tmp = Integer.valueOf(line);
if (tmp < 10000 || tmp > 99999) {
throw new Exception();
} else {
int a = tmp / 10000;
int b = (tmp - a * 10000) / 1000;
int c = (tmp - a * 10000 - b * 1000) / 100;
int d = (tmp - a * 10000 - b * 1000 - c * 100) / 10;
int e = tmp - a * 10000 - b * 1000 - c * 100 - d * 10;
System.out.println(a + " " + b + " " + c + " " + d
+ " " + e);
}
}
}
}
public class Test{
public static void main(String[] args) {
if(