Quantcast
Viewing all articles
Browse latest Browse all 39796

runtime error

Problem:here

Long story short: The problem is about taking inputs from the inputstream and converting from little endian to big endian and vice versa. Here is my code:

 class Little_endians {

public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int x;
String str;
while((str=br.readLine())!=null){
    x=Integer.parseInt(str);
    System.out.println(x+" converts to "+Integer.reverseBytes(x));//converting to the other endian just requires to reverse the bytes
    }
 }
 }

It works on all the sample inputs given but on submission it showed: Your submission for the problem 594 - One Little, Two Little, Three Little Endians has failed with verdict Runtime error.This means that the execution of your program didn't finish properly. Remember to always terminate your code with the exit code 0.

I think probably throws IOException takes care of the exit code 0.Could anyone help me find the cause for the runtime error.


Viewing all articles
Browse latest Browse all 39796

Trending Articles



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