6.Write a procedure that receives a two dimensional array th
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/21 16:54:45
6.Write a procedure that receives a two dimensional array that has been filled with integers.Use
请解释每步的意思
Write a procedure that receives a two dimensional array that has been filled with integers.Use two “for loops” to search through the array to find any value greater than 7.When a value is found that is greater than 7 then the value and its location within the array must be printed to the screen.(“Value found was “7” at [1][3]”).
请解释每步的意思
Write a procedure that receives a two dimensional array that has been filled with integers.Use two “for loops” to search through the array to find any value greater than 7.When a value is found that is greater than 7 then the value and its location within the array must be printed to the screen.(“Value found was “7” at [1][3]”).
public class Finder {
public static void find(int[][] d){
for(int i = 0;i < d.length; i++){
for(int j = 0;j < d.length;j++){
if(d[i][j] > 7){
String s = "Value found was 7 at "
+ "[" + i + "]" + "[" + j + "]";
System.out.println(s);
}
}
}
}
public static void main(String[] args) {
int[][] test = {
{
7,8,9,10,11
},
{
7,8,9,10,11
},
{
7,8,9,10,11
},
{
7,8,9,10,11
},
{
7,8,9,10,11
},
};
Finder.find(test);
}
}
再问: 能标注下每步的意思么
再答: for(int i = 0;i < d.length; i++){ //for{}for{}遍历数组 for(int j = 0;j < d.length;j++){ if(d[i][j] > 7){ //找到大于7的数 String s = "Value found was 7 at " + "[" + i + "]" + "[" + j + "]";//打印出找到的这个数的i,j System.out.println(s); } } } 这个代码很简单了,基本不需要解释,除非你没好好看书
public static void find(int[][] d){
for(int i = 0;i < d.length; i++){
for(int j = 0;j < d.length;j++){
if(d[i][j] > 7){
String s = "Value found was 7 at "
+ "[" + i + "]" + "[" + j + "]";
System.out.println(s);
}
}
}
}
public static void main(String[] args) {
int[][] test = {
{
7,8,9,10,11
},
{
7,8,9,10,11
},
{
7,8,9,10,11
},
{
7,8,9,10,11
},
{
7,8,9,10,11
},
};
Finder.find(test);
}
}
再问: 能标注下每步的意思么
再答: for(int i = 0;i < d.length; i++){ //for{}for{}遍历数组 for(int j = 0;j < d.length;j++){ if(d[i][j] > 7){ //找到大于7的数 String s = "Value found was 7 at " + "[" + i + "]" + "[" + j + "]";//打印出找到的这个数的i,j System.out.println(s); } } } 这个代码很简单了,基本不需要解释,除非你没好好看书
6.Write a procedure that receives a two dimensional array th
英语翻译Write a function that dynamically allocates an array of
Write a program that initializes array of 10 elements,Each e
/** Write a class Square whose constructor receives the leng
英语翻译4.Conclusions 1.A two-dimensional thermo-mechanical fini
英语翻译Rarely is subsurface structure one- or two-dimensional a
it is not unusual that a journalist receives severe warnings
a array of quention
英语翻译it can be displayed as a two -dimensional image through
Write a function generating 40 random integers of an array w
Describing a process or procedure
write a program that scans the initial "IbM" and replaces th