Thursday, 24 July 2014

594 One Little, Two Little, Three Little Endians


/**
 * @author Divyanshu
 * @mail divyanshu17x@gmail.com
 * @veredict Accepted
 * @problemId 594
 * @problemName One Little, Two Little, Three Little Endians
 * @judge http://uva.onlinejudge.org/
 * @category Manipulate Bit STtring
 * @level easy
 * @date 24/07/2014
 **/



import java.io.BufferedReader;

import java.io.InputStreamReader;


public class Main{
public static void main (String args[]) throws Throwable{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int number ;
String str ;
while( (str = in.readLine()) != null )
{
number = Integer.parseInt(str);

System.out.println(number + " converts to " + Integer.reverseBytes(number)); //reversesBytes swaps the bytes to change from one endian to other with 2'scompliment compatability

}
}
}

No comments:

Post a Comment