Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. public static void main(String[] args) {
  2.        
  3.         //Declaramos una matriz 3x3    
  4.         int v[][] = new int[3][3];                    
  5.                
  6.                 //Lennamos la matriz  
  7.                 for(int i=0;i<v.length;i++){
  8.                 for(int j=0;j<v.length;j++){
  9.                        
  10.                         // recorrido de la matriz
  11.                         if(i==j){
  12.                                 v[i][j] = 0;
  13.                         }else{
  14.                                 if(j>i){
  15.                                         v[i][j] = 1;
  16.                                 }else{
  17.                                         v[i][j] = 2;
  18.                                 }
  19.                                
  20.                         }
  21.                        
  22.                 }
  23.        
  24.         }
  25.                 //Para mostrar la matriz
  26.                 String mensaje="\n";
  27.                 for(int i=0;i<v.length;++i){
  28.                         for(int j=0;j<v.length;++j){
  29.                                 mensaje+=", "+v[i][j];
  30.                         }
  31.                         mensaje+="\n";
  32.                 }      
  33.  
  34.                 System.out.println(""+mensaje);
  35.     }