Programación General > Java
Necesito De Ustds Para Encontrar El Error
(1/1)
digichap28:
Hola que tal como estan??
Bueno yo no tan bien, esto es urgente, necesito de su ayuda por favor.
Es una de las notas finales del semestre.
Aqui va lo que hice, no entiendo porque no me escribe nada!!! Que esta pasando ??? no tengo ni idea!!! ya revise el codigo pero no encuentro problemas(por lo menos hasta donde yo veo).
ES UN RECORRIDO DE MATRIZ.
--- Citar ---import javax.swing.*;
public class recorrido {
public static void main (String [] args) {
int i,j,k,n,m,s;
int a[][] = new int [10][10];
int v[] = new int [100];
String st;
n=Integer.parseInt(JOptionPane.showInputDialog("n° filas"));
m=Integer.parseInt(JOptionPane.showInputDialog("n° columnas"));
for (i=1;i<=n;i++){
for(j=1;j<=m;j++){
a[j]=Integer.parseInt(JOptionPane.showInputDialog("a[ "+i+j+ " ]="));
}
}
if(n % 2==0){
k=0;
for(i=n;i<=1;i--){
if(i % 2==0){
for(j=m;j<=1;j--){
k++;
v[k]=a[j];
}
}else{
for (j=1;j<=m;j++){
k++;
v[k]=a[j];
}
}
}
}else{
k=0;
for(i=n;i<=1;i--){
if(i % 2!=0){
for(j=m;j<=1;j--){
k++;
v[k]=a[j];
}
}else{
for(j=1;j<=m;j++){
k++;
v[k]=a[j];
}
}
}
}
st=" ";
for (s=1;s<=k;s++){
st= st + v + " ";
}
JOptionPane.showMessageDialog(null, st );
}
}
--- Fin de la cita ---
ESTE ES EL RECORRIDO QUE DEBE HACERSE.
ETCETERA
| <-------- |
| --------> |
| <-------- |
| --------> |
| <-------- | (inicio)
logicaemp:
Tienes que hacer los 4 cambios indicados en el siguiente código:
--- Código: Text ---import javax.swing.*;public class recorrido { public static void main (String [] args) { int i,j,k,n,m,s; int a[][] = new int [10][10]; int v[] = new int [100]; String st; n=Integer.parseInt(JOptionPane.showInputDialog("n° filas")); m=Integer.parseInt(JOptionPane.showInputDialog("n° columnas")); for (i=1;i<=n;i++){ for(j=1;j<=m;j++){ a[i][j]=Integer.parseInt(JOptionPane.showInputDialog("a[ "+i+j+ " ]=")); } } if(n % 2==0){ k=0; for(i=n;i<=1;i--){ // ********** "<=" cambiar ">=" if(i % 2==0){ for(j=m;j<=1;j--){ // ********** "<=" cambiar ">=" k++; v[k]=a[i][j]; } }else{ for (j=1;j<=m;j++){ k++; v[k]=a[i][j]; } } } }else{ k=0; for(i=n;i<=1;i--){ // ********** "<=" cambiar ">=" if(i % 2!=0){ for(j=m;j<=1;j--){ // ********** "<=" cambiar ">=" k++; v[k]=a[i][j]; } }else{ for(j=1;j<=m;j++){ k++; v[k]=a[i][j]; } } } } st=" "; for (s=1;s<=k;s++){ st= st + v[s] + " "; } JOptionPane.showMessageDialog(null, st ); }}
Saludos,
digichap28:
MUCHAASSS GRACIAS
THANKS A LOT
ARIGATOU
Y NO SE QUE OTRO IDIOMA :D
NOTA:OJALA ESTE CODIGO LE SIRVA A ALGUIEN MAS :hola: :hola:
Navegación
Ir a la versión completa