- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *concat(char *a, char *b)
{
char *ptr = malloc(strlen(a)+strlen(b)+6);
if (ptr == NULL)
{
fprintf(stderr, "da ty ohuel!\n");
exit(-1);
}
sprintf(ptr, "(%s)*(%s)", a, b);
return ptr;
}
char *govno[255] = {"a"};
void printfshit(const size_t pow, const char *mul_stuff)
{
printf("double pow_%zu(double a) {return %s;}\n\n", pow, mul_stuff);
}
void genshit(void)
{
//printfshit(0,"1");
size_t end_ind = 1;
size_t prev_stop = 0;
size_t end_ind_tmp = 1;
while (end_ind < 255)
{
for (size_t ind1 = 0; ind1 < end_ind_tmp; ind1++)
{
for (size_t ind2 = prev_stop; ind2 < end_ind_tmp; ind2++)
{
if (
((ind1+1) + (ind2+1) < 256) &&
(govno[(ind1+1) + (ind2+1)-1] == NULL)
)
{
govno[(ind1+1) + (ind2+1)-1] = concat(govno[ind1], govno[ind2]);
end_ind++;
}
}
}
prev_stop = end_ind_tmp;
end_ind_tmp = end_ind;
}
printfshit(1,govno[0]);
for (size_t i = 1; i < 255; i++ )
{
printfshit(i+1,govno[i]);
free(govno[i]);
}
}
int main(void)
{
genshit();
return 0;
}