Created
February 7, 2023 07:48
-
-
Save sanabanana-png/67273bfbd3c5facfd3f5e3601879c804 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
public class ex53 { | |
public static void main(String[] args) { | |
printGrid(3, 6); | |
} | |
public static void printGrid(int rows, int cols) { | |
for (int line = 1; line <= rows; line++) { | |
for (int lineNum = line; lineNum <= (rows*cols) - rows; lineNum = lineNum + rows) { | |
System.out.print(lineNum); | |
System.out.print(", "); | |
} | |
System.out.print((((rows*cols)-rows))+line); | |
System.out.println(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment