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
#include <vector> | |
#include <algorithm> | |
#include <iostream> | |
#define IN | |
#define OUT | |
typedef std::vector<int> int_v; | |
inline int diff(int a, int b) | |
{ return (a < b)? (b - a) : (a - b); } |
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
require 'csv' | |
#================================================== | |
# Math Util Methods | |
#================================================== | |
def factorial(i) | |
ans = 1 | |
1.upto(i) { |x| ans *= x } | |
return ans | |
end |
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
require 'csv' | |
CSV_Output = false | |
#================================================== | |
# Math Util Methods | |
#================================================== | |
def factorial(i) | |
ans = 1 | |
1.upto(i) { |x| ans *= x } |
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
#include <iostream> | |
#include <boost/random.hpp> | |
using namespace boost; | |
int main(void) | |
{ | |
boost::mt19937 gen(static_cast<double>(time(0))); | |
boost::uniform_real<> range(0, 1); | |
boost::variate_generator< boost::mt19937, boost::uniform_real<> > random(gen, range); |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
char str_a[] = "bcdefghijklmnopqrstuvwxyz"; | |
char str_b[] = "bdfpqa"; | |
int max_3(int v1, int v2, int v3) | |
{ |
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
class SampleClass | |
def send(method_name, *args) | |
puts "#{method_name}, #{args}\n" | |
end | |
def method_missing(method_name, *args) | |
if method_name.to_s.match(/get_(.*)?_value/) | |
puts "Getter: #{$1}" | |
elsif method_name.to_s.match(/set_(.*?)_value/) | |
puts "Setter: #{$1}" |
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
#define ATTR_READER(name,type) \ | |
public: \ | |
type get_ ## name(void) { \ | |
return this-> name; \ | |
} | |
#define ATTR_WRITER(name,type) \ | |
public: \ | |
void set_ ## name(type new_val) { \ | |
this-> name = new_val; \ |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#define cleanup_free_scope __attribute__((cleanup(my_free))) | |
#define cleanup_print_scope __attribute__((cleanup(my_print_int))) | |
void my_print_int(int *i) | |
{ | |
printf("argument = %d\n", *i); | |
} |
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
#include <stdio.h> | |
/* When compiling, set 'finstrument-functions'! | |
* | |
* gcc -finstrument-functions hook.c | |
* | |
* フックされた時に呼ばれる関数の定義は、macの場合、profile_func_enter, profile_func_exitにしないと | |
* いけないみたい。Linuxの場合は頭に__cyg_をそれぞれ付ける(LINUXの場合はマングリングしないはずだから_は気にしない。) | |
*/ |
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
#include <stdio.h> | |
__attribute__((constructor)) | |
int pre_main(void) | |
{ | |
printf("%s\n", __func__); | |
getchar(); | |
return 0; | |
} |
OlderNewer