Results 1 to 3 of 3
  1. #1
    spinter is offline Member
    Join Date
    Oct 2011
    Posts
    18
    Rep Power
    0

    Default how to resolve last funtion

    well I expose th prblem I have a function that resolve the square root of a int on recursive mode , other funtion that says if a matrix is ssymmetric or not in a recursive mode, an the last function must say if the matrix of the square root of the elements is symmetric or not in a recursive mode too, i know i must use the 2 funtion before but always i have the same exception stack overflow i put here the code i have
    Java Code:
    package main; 
    
    
    
    /**
     *
     * @author adriandelasmatas
     */
    public class Main {
             public static final int i = 4;
    	 public static final  int j = 4;
    	 public static int x = 0;
    	 public static int y = 0;
             public static boolean sym = true;
    	 public static  int m[][] = new int[i][j];
             public static int n ;
             public static int r;
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
             m[0][0]=1;
                    m[1][0]= 4;
                    m[2][0]= 3;
                    m[3][0]= 2;
                    m[0][1]=4;
                    m[1][1]=1;
                    m[2][1]=2;
                    m[3][1]= 4;
                    m[0][2]=3;
                    m[1][2]=2;
                    m[2][2]=1;
                    m[3][2]=3;
                    m[0][3]=2;
                    m[1][3]=4;
                    m[2][3]=3;
                    m[3][3]=1;
          
              SqrtMatSym(m);
              System.out.println(SqrtMatSym(m));
    
       
        }
         public static int sqrt(int n) {
                                            //pre >= 0; 
           
            
                if ( (n >= (r*r)) && (n < (r+1)*(r+1)) ){  
                    return(r);  
                }else {
                    r++;
                    sqrt(n);        
                }return (r);
            }
            
        
    
        public  boolean matrix(int[][] m) {
                                                           
              if ( i == j){
                if (sym== true){                      
                        if (x != m.length - 1) {            
                            if (y == m[x].length - 1)       
                            {                              
                                if (m[x][y] != m[y][x]) {  
                                    sym = false;    
                                        }                   
                                    x++;
                                    y = 0;
                                    matrix(m);
                                } else {
    
                                    if (m[x][y] != m[y][x]) {   
                                    sym = false;
                                    } else {                    
                                        y++;
                                        matrix(m);
                                            }
                                        }
                                    }
                                 }
                            }else{
                                sym = false;}
                                        return sym;
                            }
      public static boolean SqrtMatSym(int[][] m) {
                                                 //need to do teh sqrt of all elements and know if is sym          
              if ( i == j){
                if (sym== true){   
                    
                        if (x != m.length - 1) {            
                            if (y == m[x].length - 1) {
                                
                                                       
                                if (m[x][y] != m[y][x]) {  
                                    sym = false;      
                                        }                  
                                    x++;
                                    y = 0;
                                    SqrtMatSym(m);
                                } else {
                                
                                    if (m[x][y] != m[y][x]) {   
                                    sym = false;
                                    } else {                    
                                        y++;
                                        SqrtMatSym(m);
                                            }
                                        }
                                    }
                                 }
                            }else{
                                sym = false;}
                                        return sym;
                            }
                        }

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,784
    Rep Power
    7

    Default Re: how to resolve last funtion


  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. help me to resolve this error
    By akiravelmont in forum Web Frameworks
    Replies: 3
    Last Post: 05-17-2011, 02:04 PM
  2. any one help me to resolve this error
    By akiravelmont in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 03-11-2011, 06:06 PM
  3. how to resolve this error???
    By 10e5x in forum New To Java
    Replies: 1
    Last Post: 01-21-2011, 07:40 AM
  4. funtion of close() method?
    By hacikho in forum New To Java
    Replies: 7
    Last Post: 10-11-2010, 01:08 AM
  5. Yet another Cannot Resolve Symbol
    By Gabinka in forum New To Java
    Replies: 5
    Last Post: 03-27-2009, 10:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •