Please help with my twodimensional array source code
Posted
by Baiba
on Stack Overflow
See other posts from Stack Overflow
or by Baiba
Published on 2010-03-20T20:59:09Z
Indexed on
2010/03/20
21:01 UTC
Read the original article
Hit count: 191
java
Here is what i have done but i have some questions:
class masivins { public static void main (String args[]) {
int mas[][] = {{0, 2, 7, 0, 8, 5, 3},
{0, 4, 0, 6, 0, 0, 0},
{0, 0, 0, 0, 3, 0, 0},
{7, 0, 0, 9, 1, 0, 7},
{5, 0, 4, 0, 0, 2, 0}};
int nulmas[] = new int [7];
int nul=0;
for(int j=0; j<7; j++) {
nul=0;
for(int i=0; i<5; i++) {
if(mas[i][j]==0) {
nul++;
}
}
nulmas[j]=nul;
}
for(int i=0; i<5; i++) {
for(int j=0; j<7; j++) {
System.out.println(mas[i][j]);
}
System.out.println();
}
System.out.println();
for(int i=0; i<5; i++) {
System.out.println("Zeros in each array column: " + nulmas[i]);
}
System.out.println();
}
}
so my questions are: 1) why after running project there are only 5 "Zeros in each array column....." shown? 2) what and where i need to change in this code to get out the number of column in which zeros are least?
© Stack Overflow or respective owner