#include #include #include const char * baseSvgFull = "\n\ \n\ \n\ \n\ \n\ "; const char * baseSvg = "\n\ \n\ \n\ "; const char * endSvg = ""; const char * lines[] = { " ", " ", " " }; const unsigned short VERTICES = 3; unsigned short CONNECTIONS; unsigned short POSSIBILITIES; unsigned short connections (unsigned short n); /* builds all possible triangles */ int main(int argc, char *argv[]) { unsigned short x, bitop, mask; CONNECTIONS = connections(VERTICES); POSSIBILITIES = (unsigned short) pow(2, CONNECTIONS); for (x = 0; x < POSSIBILITIES; x++) { printf("%s\n", baseSvg); for (bitop = 0; bitop < CONNECTIONS; bitop++) { mask = ((unsigned short) pow(2, bitop)) & x; if (mask > 0) { printf("%s\n", lines[bitop]); } } printf("%s\n\n", endSvg); } return(EXIT_SUCCESS); } unsigned short connections (unsigned short n) { unsigned short x = 0; while (n > 0) x += --n; return(x); }