close

/*輸入一串數字, 寫出一數字拆解函數decomp(n), 將其個別數字用空白分開
(ex: 輸入 128917178, 輸出 1 2 8 9 1 7 1 7 8).
decomp(4562) 印出 4 5 6 2
decomp(8279) 印出 8 2 7 9
*/
import java.util.*;
public class Main {
public static void main(String args[])
{

String test;
System.out.print("輸入一串數字:");
Scanner scanner = new Scanner(System.in);
test = scanner.next();
//int i=Integer.parseInt(test);
System.out.print("decomp("+test+"):"+decomp(test));


}
public static String decomp(String m)
{
String[] names=m.split("");
String x="";
for(int i=1;i<m.length()+1;i++)
{
x=x+names[i];
x=x+" ";
}
m=x;
return m;
}
}

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 萌新-工程師 的頭像
    萌新-工程師

    工程師的雜記

    萌新-工程師 發表在 痞客邦 留言(0) 人氣()