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> | |
using namespace std; | |
typedef struct _node { | |
_node* left; | |
_node* right; | |
char c; | |
}node; | |
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> | |
int main(int argc, char* argv[]) { | |
std::cout << sizeof(void *) << std::endl; | |
std::cout << sizeof(int *) << std::endl; | |
std::cout << sizeof(double *) << std::endl; | |
int* p = 0x0; | |
p++; | |
if (p == (int *)0x4) { | |
std::cout << "32 bit" << std::endl; |
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 <string.h> | |
#include <stdio.h> | |
/* | |
x-axis: time id | |
y-axis: teacher/course id | |
0 1 2 | |
----------- | |
0 | 1 1 -1 | |
1 | 1 1 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
#include <pthread.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
// or syscall(224) | |
#define gettid() syscall(__NR_gettid) | |
void* thread(void* args) | |
{ | |
int tid = syscall(224); |
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> | |
struct Point{ | |
int x; | |
int y; | |
}; | |
// OpenGL front face. | |
int is_front_face(Point p0, Point p1, Point p2) { |
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> | |
struct Link { | |
// use the general pointer to point out. | |
void* p; | |
Link* next; | |
}; | |
// init a link. |
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 <cassert> | |
#include <cmath> | |
using namespace std; | |
char a[3] = { '+', '+', '+' }; | |
int i = 0; | |
const int base = 4; /* [+,-,*,/] */ |
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> | |
using namespace std; | |
/* | |
Grammar: | |
E -> \0 | F; | |
F -> d\0 | d+F; | |
*/ | |
char look_first; |
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 false true | |
#define while if | |
#define NULL ::rand() % 2 | |
#define return return ::rand() * | |
int main(int argc, char* argv[]) { | |
while (false) { |
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> | |
int main(int argc, char* argv[]) { | |
int x = 0; | |
while (1) { | |
x++; | |
if (x < 0 && -x < 0) { | |
printf("%d %x\n", x, x); | |
printf("%d\n",-x + x); | |
break; |
NewerOlder