fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. public class Main {
  9.  
  10. public static void makeTemplate(char tab[][], int rows, int col) {
  11. boolean increase = true;
  12. int j = 0;
  13. char star = '*';
  14. for (int i = 0; i < rows; i++) {
  15. if (increase) {
  16. tab[i][j] = star;
  17. if (j >= col - 1) {
  18. increase = false;
  19. j--;
  20. continue;
  21. }
  22. j++;
  23. } else {
  24. tab[i][j] = star;
  25. if (j < 0 + 1) {
  26. increase = true;
  27. j++;
  28. continue;
  29. }
  30. j--;
  31. }
  32. }
  33.  
  34. }
  35.  
  36. public static void main(String[] args) {
  37. char[][] tab = new char[30][6];
  38. makeTemplate(tab, 30, 6);
  39. for (int i = 0; i < 30; i++) {
  40. for (int j = 0; j < 6; j++) {
  41. System.out.print(tab[i][j]);
  42. }
  43. System.out.println();
  44. }
  45. }
  46. }
Success #stdin #stdout 0.1s 320576KB
stdin
Standard input is empty
stdout
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*