Last active
August 29, 2015 14:04
-
-
Save resetter/1278a6f67e84f686669b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
public class MinOccurance2 | |
{ | |
public static void main (String[] args) throws IOException | |
{ | |
int[] occur = new int[256]; | |
int Current = 0; | |
RandomAccessFile file = new RandomAccessFile("test.txt", "r"); | |
long length = file.length(); | |
for ( int i = 0; i < length; i++) { | |
Current = file.read(); | |
int highNibble = Current >>> 4 ; | |
int lowNibble = Current & 0x0f; | |
occur[highNibble]++; | |
occur[lowNibble]++; | |
} | |
for ( int k = 0; k < 4; k++) { | |
System.out.println(k + " " + occur[k]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment