Java - arreglo unidimencionales

 
Vista:

arreglo unidimencionales

Publicado por leo (1 intervención) el 24/07/2009 03:03:20
int fi=Integer.parseInt(txtfila.getText());
int col=Integer.parseInt(txtcolumna.getText());
String[][] numeros=new String[fi][col];
int loca=0;
for (int f = 0; f < fi ; f++) {
loca++;
for (int c = 0; c < col; c++) {
numeros[f][c]="+";
if(c>loca-2){
numeros[f][c]="*";
}
}
}

String fila="";
for (int f = 0; f < fi; f++) {
for (int c = 0; c < col; c++) {
fila +=String.valueOf(numeros[f][c]+" ");
}
fila+=" ";
}
txtarea.setText(fila);
}


nuevo codiguo

int fil=Integer.parseInt(txtfila.getText());
int colu=Integer.parseInt(txtcolumna.getText());
int [][]mnumeros=new int [fil] [colu];
int res=1;
for(int f=0; f< fil;f++){
for(int c=0;c<colu; c++){
res= fil*colu;
mnumeros[f][c]=8;
}

}
String fila="";
for(int f=0; f<fil; f++){
for(int c=0; c<colu; c++){
fila+=String.valueOf(res--)+" ";
}
fila+=" ";
}
txtarea.setText(fila);
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder