完了済

This commit is contained in:
2026-10-09 16:21:02 +09:00
parent 8153c32000
commit 8c3324660c
41 changed files with 773 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
public class Question7_1 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
int nums[] = new int[5];
nums[0] = 1;
nums[1] = 3;
nums[2] = 5;
nums[3] = 7;
nums[4] = 9;
System.out.println(nums[1]);
}
}

View File

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

View File

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

View File

@@ -0,0 +1,15 @@
public class Question7_3 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
String[] str = {"森","山","沼","島","平地"};
for ( int i=0 ; i<str.length ; i++ ) {
System.out.println(str[i]);
}
}
}

View File

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

View File

@@ -0,0 +1,14 @@
public class Question7_5 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
String[] str = {"森","山","沼","島","平地"};
int num = (int)( Math.random()*5 );
System.out.println(str[num]);
}
}

View File

@@ -0,0 +1,14 @@
public class Question7_6 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
String[] str = {"森","山","沼","島","平地"};
for ( int i=str.length ; i>0 ; i-- ) {
System.out.println(str[i-1]);
}
}
}

View File

@@ -0,0 +1,19 @@
public class Question7_7 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
String[][] table = {
{"国語","社会","国語","理科","社会"},
{"英語","数学","英語","数学","国語"},
{"理科","国語","理科","国語","理科"},
{"社会","社会","数学","社会","数学"},
{"数学","英語","英語","理科","英語"}
};
System.out.println(table[1][4]);
}
}

View File

@@ -0,0 +1,20 @@
public class Question7_8 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
int[][] array = {
{1,3,5,7},
{11,13,17,19,23,29}
};
for ( int i=0 ; i<array.length ; i++) {
for ( int j=0 ; j<array[i].length ; j++ ) {
System.out.println(array[i][j]);
}
}
}
}

View File

@@ -0,0 +1,24 @@
public class Question7_9 {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
int[][] array = {
{1,3,5,7},
{11,13,17,19,23,29}
};
int count=0;
double sum=0;
for ( int i=0 ; i<array.length ; i++) {
for ( int j=0 ; j<array[i].length ; j++ ) {
sum += array[i][j];
count++;
}
}
System.out.println(sum/count);
}
}