Galera,
Já consgui fazer, vejam como ficou:
import java.util.Scanner;
public class sortMatriz {
public static void main(String[] args){
int linhas=0, colunas=0;
int valor;
int aux=0;
System.out.print("Linhas:");
linhas=(new Scanner(System.in)).nextInt();
System.out.print("Colunas");
colunas=(new Scanner(System.in)).nextInt();
int[][] mat = new int[linhas][colunas];
for(int x=0;x<linhas;x++){
for(int y=0;y<colunas;y++){
System.out.print("Informa valor da linha "+x+" e coluna
"+y);
//isso tava errado
mat[x][y]=(new Scanner(System.in)).nextInt();
}
}
for(int z=0;z<linhas;z++){
for(int y=0;y<colunas;y++){
for(int x=0;x<linhas-1;x++){
if(mat[x][y]>mat[x+1][y]){
aux = mat[x][y];
mat[x][y] = mat[x+1][y];
mat[x+1][y] = aux;
}
}
}
}
for(int x=0;x<linhas;x++){
for(int y=0;y<colunas;y++){
System.out.println("Na linha "+x+" coluna "+y+"
valor"+mat[x][y]);
}
}
}
}
2009/10/30 Pablo Souza <pvrsouza@gmail.com>
> Na verdade eu não tenho esta mania não!
> Nesse caso ai como estava aguniado tentando ordenar a matriz acabei
> deixando passa isso. Mas sempre faço do jeito que indicou!
>
> Abs e brigado pela dica!
>
>
>
> 2009/10/30 db <dbconrado@gmail.com>
>
>
>>
>> Não fique construindo um Scanner toda a hora em que vc for ler alguma
>> coisa
>> do teclado.
>> Crie um só, tipo assim:
>> Scanner sc = new Scanner(System.in);
>> int linhas = sc.nextInt();
>> int colunas = sc.nextInt();
>>
>>
>> public class sortMatriz {
>>
>> > public static void main(String[] args){
>> > int linhas=0, colunas=0;
>> > int valor;
>> > int aux=0;
>> >
>> > System.out.print("Linhas:");
>> > linhas=(new Scanner(System.in)).nextInt();
>> > System.out.print("Colunas");
>> > colunas=(new Scanner(System.in)).nextInt();
>> > int[][] mat = new int[linhas][colunas];
>> > for(int x=0;x<linhas;x++){
>> > for(int y=0;y<colunas;y++){
>> > System.out.print("Informa valor:");
>> > valor=(new Scanner(System.in)).nextInt();
>> > Vc tem que salvar o valor na matriz! tipo: mat[x][y]=valor
>>
>> >
>> }
>> > }
>> > for(int y=0;y<colunas;y++){
>> > for(int x=0;x<linhas-1;x++){
>> > if(mat[y][x]>mat[y][x+1]){
>> > aux = mat[y][x];
>> > mat[y][x] = mat[y][x+1];
>> > mat[y][x+1] = aux;
>> > }
>> > }
>> > }
>> > for(int x=0;x<linhas;x++){
>> > for(int y=0;y<colunas;y++){
>> > System.out.println("Na coluna "+x+" linha "+y+"
>> > valor"+mat[colunas][linhas]); <-- o erro que vc falou tá aqui. vc quis
>> > dizer: mat[y][x]?
>> > }
>> > }
>> > }
>> > }
>> > espero ter ajudado.
>> > abraços
>> > --db
>> >
>>
>> [As partes desta mensagem que não continham texto foram removidas]
>>
>>
>>
>
>
>
> --
> Atenciosamente,
>
> Pablo Souza
> Tel.: (71) 9983-7775
>
--
Atenciosamente,
Pablo Souza
Tel.: (71) 9983-7775
[As partes desta mensagem que não continham texto foram removidas]