问题描述
编写一个程序,输入一个1000 以内的正整数,然后把这个整数的每一位数字都分离出来,并逐一地显示。
输入格式:输入只有一行,即一个1000以内的正整数。
输出格式:输出只有一行,即该整数的每一位数字,之间用空格隔开。
输入输出样例
样例输入
769
样例输出
7 6 9
资源限制
时间限制:1.0s 内存限制:512.0MB
代码块:
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String str = n+"";
char[]c = str.toCharArray();//转化为字符数组
for(int i = 0; i < str.length(); i++){
System.out.print(c[i]+" ");
}
}
}