added some tree fun stuff :D
This commit is contained in:
parent
a7e157b446
commit
acdcdb2399
3 changed files with 45 additions and 3 deletions
|
|
@ -8,6 +8,27 @@
|
|||
#include <stdio.h>
|
||||
#include "tree.h"
|
||||
|
||||
char* gen_boop(){ // generates the "boop" string
|
||||
Node b;
|
||||
b.value = 'b';
|
||||
Node o;
|
||||
o.value = 'o';
|
||||
b.left = &o;
|
||||
Node p;
|
||||
p.value = 'p';
|
||||
o.left = &p;
|
||||
Node end;
|
||||
end.value = '\0';
|
||||
o.right = &end;
|
||||
char* res = (char*) malloc(sizeof(char)*5);
|
||||
res[0] = b.v();
|
||||
res[1] = b.l()->v();
|
||||
res[2] = b.l()->v();
|
||||
res[3] = b.l()->l()->v();
|
||||
res[4] = b.l()->r()->v();
|
||||
return res;
|
||||
}
|
||||
|
||||
char* this_is_useful_fr_dont_miss_it(){ // it's not, pure red herring
|
||||
char* useful = (char*) malloc(sizeof(char)*100);
|
||||
|
||||
|
|
@ -34,7 +55,7 @@ int _tmain(int argc, wchar_t* argv[])
|
|||
e[i] = (char)argv[1][i]^'\x00';
|
||||
}
|
||||
e[8] = '\0';
|
||||
sprintf(d, "%s%s", c, "boop\0baap");
|
||||
sprintf(d, "%s%s%s", c, gen_boop(), "\0baap");
|
||||
d[9] = '\0'; // pure bait
|
||||
if (!strcmp(d, e)) {
|
||||
printf("Gagne!\n");
|
||||
|
|
@ -44,7 +65,7 @@ int _tmain(int argc, wchar_t* argv[])
|
|||
} else {
|
||||
printf("Et il est où l'argv???????");
|
||||
}
|
||||
while(1);
|
||||
// while(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
#include "tree.h"
|
||||
#include "tree.h"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
#include <cstddef>
|
||||
|
||||
class Node {
|
||||
public:
|
||||
Node* left;
|
||||
Node* right;
|
||||
char value;
|
||||
Node* l(){
|
||||
return left;
|
||||
}
|
||||
Node* r(){
|
||||
return right;
|
||||
}
|
||||
char v(){
|
||||
return value;
|
||||
}
|
||||
bool is_leaf(){
|
||||
return left == NULL && right == NULL;
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue