Skip to content

Instantly share code, notes, and snippets.

@rapisenpai
Last active November 17, 2023 15:03
Show Gist options
  • Save rapisenpai/8c3004d4e3fee069043c0af726bc67ca to your computer and use it in GitHub Desktop.
Save rapisenpai/8c3004d4e3fee069043c0af726bc67ca to your computer and use it in GitHub Desktop.
class MeElidaSalise {
public static void main(String[] args) {
// Problem 1
System.out.println("Problem 1");
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(j + " ");
}
System.out.println();
}
// Problem 2
System.out.println("\nProblem 2");
int count = 1;
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(count + " ");
count++;
}
System.out.println();
}
// Problem 3
System.out.println("\nProblem 3");
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(j + " ");
}
System.out.println();
}
// Problem 4
System.out.println("\nProblem 4");
for (int i = 1; i <= 5; i++) {
int temp = i;
for (int j = 1; j <= i; j++) {
System.out.print(temp + " ");
temp--;
}
System.out.println();
}
// Problem 6
System.out.println("\nProblem 6");
for (int i = 5; i >= 1; i--) {
for (int j = 1; j <= i; j++) {
System.out.print(j + " ");
}
System.out.println();
}
// Problem 7
System.out.println("\nProblem 7");
for (int i = 5; i >= 1; i--) {
for (int j = 1; j <= i; j++) {
System.out.print(i + " ");
}
System.out.println();
}
// Problem 8
System.out.println("\nProblem 8");
int k = 1;
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(k + " ");
k++;
}
System.out.println();
}
// Problem 9
System.out.println("\nProblem 9");
for (int i = 5; i >= 1; i--) {
for (int j = i; j <= 5; j++) {
System.out.print(j + " ");
}
System.out.println();
}
// Problem 10
System.out.println("\nProblem 10");
for (int i = 5; i >= 1; i--) {
for (int j = 5; j >= i; j--) {
System.out.print(i + " ");
}
System.out.println();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment