This file contains 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
public class BitConvertNumbers { | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
System.out.println( bitSwapRequired( 1089, 7 ) ); | |
} |
This file contains 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
public class TestFloat { | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
//System.out.println( "Please input a real number between 0 and 1, 0.72 for example:" ); | |
This file contains 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
public class InsertBinary { | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
int n = 1089; | |
int m = 7; | |
int i = 2; |
This file contains 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
//assume x1 < x2 | |
drawHorizontalLine( byte[] screen, int width, int x1, int x2, int y ) { | |
int start = y * width / 8 + ( int ) x1 / 8; | |
int end = y * width / 8 + ( int ) x2 / 8; | |
for ( int i = start; i <= end; i++ ) { | |
screen[ i ] = 127; | |
} | |
if ( start == end ) { | |
screen[ start ] = screen[ start ] >> ( x1 % 8 ); |
This file contains 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.util.Scanner; | |
public class StringCompression { | |
private static Scanner in; | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) { |
This file contains 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
public static void main( String[] args ) { | |
String s11 = s1 + s1; | |
if ( isSubstring( s11, s2 ) ) | |
System.out.println( "s2 is a rotation of s1."); | |
else | |
System.out.println( "s2 is not a rotation of s1." ); | |
} | |
//check if s2 is a substring of s1 | |
public static boolean isSubstring( String s1, String s2 ) { |
OlderNewer