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
| void PrintLongN(int N, const char *str) | |
| { | |
| //error check | |
| if (N <=0 || *str == NULL) | |
| { | |
| assert(0); | |
| printf("error! \n"); | |
| return; | |
| } | |
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
| int main(int argc, const char * argv[]) | |
| { | |
| //#pragma pack(push) | |
| #pragma pack(4) | |
| struct align_test | |
| { | |
| char x; //1 byte | |
| int y; //4 bytes | |
| short int z; //2bytes |
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
| class BB | |
| { | |
| private: | |
| int aa, bb; | |
| public: | |
| BB():aa(1),bb(5) //note: check about default value assign aa, bb depends on compiler. DON'T WRITE LIKE THAT | |
| { | |
| printf("Print out value aa = %d, bb=%d \n", aa, bb); | |
| bb = aa; | |
| printf("Print out value bb = %d \n", bb); |
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
| def logstn(strs, number) | |
| while (number >0) | |
| logest = strs.inject do |first, second| | |
| (first.length > second.length)? first : second | |
| end | |
| puts logest | |
| strs.delete_if {|x| x==logest} | |
| number -= 1 | |
| end | |
| end |
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
| #Ruby | |
| puts " ----------------------- Basic moniplation --------------" | |
| i=1 | |
| k="ss" | |
| i=i+1 | |
| I=2 | |
| I=I+2 | |
| puts k | |
| puts i | |
| puts k+i.to_s #不可直接轉型~這是基本提供轉型與轉字串 |
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
| class foo_class | |
| { | |
| foo_class() | |
| private: | |
| int a=0; | |
| public: | |
| int b=0, | |
| void foo_fun1(); | |
| } |
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
| def quickSort_bigendian(input_arry) | |
| index_i = 0 | |
| puts "Before sort" | |
| puts input_arry.inspect | |
| while (index_i < input_arry.size) | |
| index_j = input_arry.size | |
| index_j -= 1 | |
| while (index_j > index_i) | |
| if ( input_arry[index_j] < input_arry[index_j-1] ) | |
| temp = input_arry[index_j-1] |
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
| def fibinacci(fib_number) | |
| return fib_number <= 1 ? 1 : fibinacci(fib_number - 1) + fibinacci(fib_number - 2) | |
| end | |
| puts fibinacci(1) #output 1 | |
| puts fibinacci(3) #output 3 | |
| puts fibinacci(5) #output 8 |
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
| #Ruby | |
| def to_post_pre_fix(infix, isPost = true) | |
| op_stack = [] #宣告成stack | |
| return_str = "" #宣告成string | |
| index_i=0 | |
| while (index_i < infix.size) | |
| if (infix[index_i] == ")") | |
| return_str << op_stack.pop #string operator add to back | |
| elsif ("+-*/".include? infix[index_i]) | |
| isPost ? op_stack.push(infix[index_i]) : return_str << infix[index_i] |
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
| #include <iostream> | |
| #include <stdio.h> | |
| class aClass | |
| { | |
| private: | |
| int a1=1; | |
| public: | |
| aClass():a1(2), a2(3) | |
| { |
OlderNewer