42 lines
931 B
C
42 lines
931 B
C
|
|
#include <stdio.h>
|
||
|
|
|
||
|
|
int counter = 0;
|
||
|
|
|
||
|
|
void rec (char *str) {
|
||
|
|
for (size_t i = 0; str[i] != 0; ++i) {
|
||
|
|
if (str[i] == '0') {
|
||
|
|
int t = ++counter;
|
||
|
|
printf(" \"%s\" -> T%d [color=black]\n", str, t);
|
||
|
|
str[i] = '+';
|
||
|
|
printf(" T%d -> \"%s\" [color=green]\n", t, str);
|
||
|
|
rec(str);
|
||
|
|
str[i] = '-';
|
||
|
|
printf(" T%d -> \"%s\" [color=red]\n", t, str);
|
||
|
|
rec(str);
|
||
|
|
str[i] = '0';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
int main2() {
|
||
|
|
char str[] = "0000\0";
|
||
|
|
printf("digraph {\n");
|
||
|
|
rec(str);
|
||
|
|
printf(" ");
|
||
|
|
if (counter > 1) {
|
||
|
|
printf("T1");
|
||
|
|
}
|
||
|
|
for (int i = 2; i <= counter; ++i) {
|
||
|
|
printf(", T%d", i);
|
||
|
|
}
|
||
|
|
if (counter > 1) {
|
||
|
|
printf(" [shape=point]");
|
||
|
|
}
|
||
|
|
printf("\n}\n");
|
||
|
|
}
|
||
|
|
|
||
|
|
int main(void) {
|
||
|
|
unsigned short int x = 65535; // 1111 1111 1111 1111
|
||
|
|
short int y = x;
|
||
|
|
printf("%d", y);
|
||
|
|
}
|