Pete1

Untitled

Mar 22nd, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PrintCharacterTriangle {
  4. public static void main(String[] args) {
  5. String letters = "abcdefghijklmnopqrstuvwxyz";
  6. Scanner sc = new Scanner(System.in);
  7. int number = sc.nextInt();
  8.  
  9. int count = 0;
  10. for (int i = 0; i < number * 2; i++) {
  11. String subString = letters.substring(0, count);
  12. for (int j = 0; j < subString.length(); j++) {
  13. System.out.print(subString.charAt(j) + " ");
  14. }
  15.  
  16. if (i != number * 2 - 1){
  17. System.out.println();
  18. }
  19.  
  20. if (i > number - 1) {
  21. count--;
  22. } else {
  23. count++;
  24. }
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment