10/8コミット

This commit is contained in:
2026-10-08 16:49:57 +09:00
parent d9529e2971
commit 2c6d1574e5
28 changed files with 343 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
public class Question6_1 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
//for文
//「++」⇒インクリメント i+1
for (int i = 1; i <100; i++) {
System.out.println(i);
}
}
}

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,17 @@
import java.util.Random;
public class Question6_5 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
Random gacha = new Random();
for (int i = 0; i < 10; i++) {
int num = gacha.nextInt(3);
if (num != 2) {
System.out.println(num);
}
}
}
}

View File

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

View File

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