Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

NZEC Error : Snape Problem

$
0
0

In the below JAVA program I am getting NZEC error without using try catch statement, but with try catch statement it runs fine . It happens almost always . I am not able to figure out that is this problem of my code or Code Chef java compiler. Please suggest solution .

import java.io.BufferedWriter;
import java.io.OutputStreamWriter;

class ClassTest 
    {
        public static void main(String args[] ) throws Exception 
        { try{
            int T=0 ,read;
             BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));

             // No of Test Cases
            while((read = System.in.read()) != '\n' ) 
            {  if( read != '\r' )                T = T*10 + read -48 ;      }


           while(T --> 0)
           {   
               int A=0,B=0 ;

                 while((read = System.in.read()) != ' ' ) 
                 {  if( read != '\r' && read != '-')                 A = A*10 + read -48  ; }

                 while((read = System.in.read()) != '\n' && read != -1 ) 
                 {  if( read != '\r' && read != '-')                 B= B*10 + read -48  ;  }

                 int a =Math.max(A,B);
                 int b =Math.min(A,B);

                 float max =(float)Math.sqrt(a*a +b*b); 
                 float min =(float)Math.sqrt((a*a)  - (b*b));

                 out.write(min + " ");
                 out.write(max + "\n");           
           }
           out.flush();
           out.close();
           System.in.close();       
        }catch(Exception e){}                                   
    }

}

Viewing all articles
Browse latest Browse all 40121

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>