Created
January 9, 2010 05:16
-
-
Save johnhmj/272737 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.Scanner; | |
public class Main { | |
// Start of main | |
public static void main(String[] args) { | |
PrintStream jout = new PrintStream(System.out); | |
Scanner jin = new Scanner(System.in); | |
jout.printf("Input a number: "); | |
// input a number | |
String a = jin.nextLine(); | |
int len = a.length(); | |
// build a char array | |
char[] b = new char[len * 2 - 1]; | |
b[0] = a.charAt(0); | |
for (int i = 1; i < len; i ++) | |
{ | |
b[i * 2 - 1] = ' '; | |
b[i * 2] = a.charAt(i); | |
} | |
String c = String.copyValueOf(b) + "\r\n"; | |
jout.printf(c); | |
}// End of main | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment