1030自主学習
This commit is contained in:
6
Question07-Array/.classpath
Normal file
6
Question07-Array/.classpath
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21"/>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="output" path="build/classes"/>
|
||||
</classpath>
|
||||
1
Question07-Array/.gitignore
vendored
Normal file
1
Question07-Array/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build/
|
||||
23
Question07-Array/.project
Normal file
23
Question07-Array/.project
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Question07-Array</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
9
Question07-Array/.settings/org.eclipse.jdt.core.prefs
Normal file
9
Question07-Array/.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -0,0 +1,9 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
|
||||
org.eclipse.jdt.core.compiler.compliance=21
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=21
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<installed facet="java" version="21"/>
|
||||
</faceted-project>
|
||||
9
Question07-Array/src/main/java/Question7_1.java
Normal file
9
Question07-Array/src/main/java/Question7_1.java
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
public class Question7_1 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
int[] nums = {1, 3, 5, 7, 9};
|
||||
System.out.println(nums[1]);
|
||||
}
|
||||
}
|
||||
16
Question07-Array/src/main/java/Question7_10.java
Normal file
16
Question07-Array/src/main/java/Question7_10.java
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
public class Question7_10 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
int[] nums = new int[100];
|
||||
|
||||
for(int i = 0; i < nums.length; i++) {
|
||||
nums[i] = i + 1;
|
||||
}
|
||||
for(int i = 0; i < nums.length; i++) {
|
||||
System.out.println(nums[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
10
Question07-Array/src/main/java/Question7_2.java
Normal file
10
Question07-Array/src/main/java/Question7_2.java
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
public class Question7_2 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
int[] nums = {1, 10, 100};
|
||||
System.out.println(nums[0] + nums[2]);
|
||||
}
|
||||
|
||||
}
|
||||
12
Question07-Array/src/main/java/Question7_3.java
Normal file
12
Question07-Array/src/main/java/Question7_3.java
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
public class Question7_3 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
String[] str = {"森", "山", "沼", "島", "平地"};
|
||||
for(int i = 0; i <= 4; i++) {
|
||||
System.out.println(str[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
15
Question07-Array/src/main/java/Question7_4.java
Normal file
15
Question07-Array/src/main/java/Question7_4.java
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
public class Question7_4 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
int[] nums = new int[1000];
|
||||
for(int i = 0; i < 1000; i++) {
|
||||
nums[i] = i + 1;
|
||||
}
|
||||
for(int i = 0; i < 1000; i++) {
|
||||
System.out.println(nums[i]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
11
Question07-Array/src/main/java/Question7_5.java
Normal file
11
Question07-Array/src/main/java/Question7_5.java
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
public class Question7_5 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
String[] str = {"森", "山", "沼", "島", "平地"};
|
||||
int num = (int)(Math.random()*5);
|
||||
System.out.println(str[num]);
|
||||
}
|
||||
|
||||
}
|
||||
12
Question07-Array/src/main/java/Question7_6.java
Normal file
12
Question07-Array/src/main/java/Question7_6.java
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
public class Question7_6 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
String[] str = {"森", "山", "沼", "島", "平地"};
|
||||
for(int i = 4; i >=0; i--) {
|
||||
System.out.println(str[i]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
28
Question07-Array/src/main/java/Question7_7.java
Normal file
28
Question07-Array/src/main/java/Question7_7.java
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
public class Question7_7 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
String[][] timetable = {
|
||||
{"国語", "社会", "国語", "理科", "社会"},
|
||||
{"英語", "数学", "英語", "数学", "国語"},
|
||||
{"理科", "国語", "理科", "国語" ,"理科"},
|
||||
{"社会", "社会", "数学", "社会", "数学"},
|
||||
{"数学", "英語", "英語", "理科", "英語"},
|
||||
};
|
||||
|
||||
System.out.println("\t 月\t 火\t 水\t 木\t 金");
|
||||
for(int i = 0; i < 5; i++) {
|
||||
System.out.print((i + 1) + "時間目");
|
||||
|
||||
for(int j = 0; j < 5; j++) {
|
||||
System.out.print("\t" + timetable[i][j]);
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
System.out.println(timetable[1][4]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
16
Question07-Array/src/main/java/Question7_8.java
Normal file
16
Question07-Array/src/main/java/Question7_8.java
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
public class Question7_8 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
int[][] nums = {
|
||||
{1, 3, 5, 7},
|
||||
{11, 13, 17, 19, 23, 29}
|
||||
};
|
||||
for(int i = 0; i < nums.length; i++) {
|
||||
for(int j = 0; j < nums[i].length; j++) {
|
||||
System.out.println(nums[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
23
Question07-Array/src/main/java/Question7_9.java
Normal file
23
Question07-Array/src/main/java/Question7_9.java
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
public class Question7_9 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
int[][] nums = {
|
||||
{1, 3, 5, 7},
|
||||
{11, 13, 17, 19, 23, 29}
|
||||
};
|
||||
int sum = 0;
|
||||
int count = 0;
|
||||
|
||||
for(int i = 0; i < nums.length; i++) {
|
||||
for(int j = 0; j < nums[i].length; j++) {
|
||||
sum += nums[i][j];
|
||||
count++;
|
||||
}
|
||||
}
|
||||
float ave = (float)sum / count;
|
||||
System.out.println(ave);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user