Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scanner in = new Scanner(System.in);
- System.out.println("This program will generate all the substrings of a given word, in increasing order of substring length.");
- System.out.println();
- System.out.printf("Please enter the word: ");
- String word = in.next();
- //String strFormatHeader = "| " + word + " | ";
- //System.out.println(wordFormatHeader);
- //int numDashes = 7 + Integer.parseInt(word);
- String dashes = "";
- int i = 1;
- int j;
- System.out.print("|");
- while (i <= word.length()){
- for (j = 0; j < word.length()-i;j++)
- {
- System.out.printf("%s|", word.substring(j,i));
- i++;
- }
- }
- }
- /* for (i = 0; i < word.length(); i++)
- {
- //for (j = 0; j < word.length(); j += 1)
- System.out.printf("%s|", word.charAt(i));
- }
- {
- System.out.println();
- }
- for (i = 0; i < word.length(); i++){
- System.out.printf("%s|", word.substring(0,i));
- i += 1;
- }
- System.out.println();
- System.out.printf("|%s|",word);
- //}
- /*for (i = 0; i < word.length(); i++)
- {
- char c = word.charAt(i);
- // System.out.printf("-");
- dashes = dashes + "-";
- System.out.println(dashes);
- String strFormatHeader = "| " + word + " | ";
- System.out.println(strFormatHeader);
- }
- System.out.println(dashes);
- //String strFormatHeader = "| " + word + " | ";
- //System.out.println(strFormatHeader);
- }*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement