java programming
Posted
by Baiba
on Stack Overflow
See other posts from Stack Overflow
or by Baiba
Published on 2010-03-20T21:33:09Z
Indexed on
2010/03/20
21:41 UTC
Read the original article
Hit count: 234
ok i have version of t code, please tell me what i need to do when i need to get out of program The INDEX NUMBER OF COLUMN IN WHICH ARE LEAST ZEROS?
class Uzd{
public static void main(String args[]){
int mas[][]= {{3,4,7,5,0},
{4,5,3,0,1},
{8,2,4,0,3},
{7,0,2,0,1},
{0,0,1,3,0}};
int nul_mas[] = new int[5];
int nul=0;
for(int j=0;j<5;j++){//
nul=0;
for(int i=0;i<5;i++){
if(mas[i][j]==0){
nul++;
}
}
nul_mas[j]=nul;
}
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
System.out.print(mas[i][j]);
}
System.out.println();
}
System.out.println();// atstarpe
System.out.println("///zeros in each column///");
for(int i=0;i<5;i++){System.out.print(nul_mas[i]);}
System.out.println();
}}
and after running it shows:
34750
45301
82403
70201
00130
///zeros in each column/// But i need not in each column but i need to get out index of column in which zeros are least! in this situation it is column nubmer 2!!
12032
© Stack Overflow or respective owner