練習問題

This commit is contained in:
2026-10-29 16:04:28 +09:00
parent d9529e2971
commit 43f53da2f2
136 changed files with 1721 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
public class Q6_1 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
for (int i = 0; i <= 99; i++) {
System.out.println(i);
}
}
}

View File

@@ -0,0 +1,16 @@
public class Q6_2 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
int count = 5;
for (int i = 0; i < count; i++) {
System.out.print("■");
}
}
}

View File

@@ -0,0 +1,13 @@
public class Q6_3 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
for(int num = 0; num <= 100; num++) {
if(num % 2 == 0) {
System.out.println(num);
}
}
}
}

View File

@@ -0,0 +1,19 @@
public class Q6_4 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
for (int n = 1; n <= 49; n++) {
if(n % 3 == 0 && n % 5 == 0) {
System.out.println("fizzbuzz");}
else if(n % 3 == 0) {
System.out.println("fizz");}
else if(n % 5 == 0) {
System.out.println("buzz");}
else
System.out.println(n);
}
}
}