Skip to content

Instantly share code, notes, and snippets.

@johnhmj
Created January 9, 2010 05:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnhmj/272737 to your computer and use it in GitHub Desktop.
Save johnhmj/272737 to your computer and use it in GitHub Desktop.
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