about summary refs log tree commit diff
path: root/usth/MATH2.3/5/automata-to-grammar.c
diff options
context:
space:
mode:
Diffstat (limited to 'usth/MATH2.3/5/automata-to-grammar.c')
-rw-r--r--usth/MATH2.3/5/automata-to-grammar.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/usth/MATH2.3/5/automata-to-grammar.c b/usth/MATH2.3/5/automata-to-grammar.c
new file mode 100644
index 0000000..430782a
--- /dev/null
+++ b/usth/MATH2.3/5/automata-to-grammar.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+int main()
+{
+	int n, b, j, k;
+
+	scanf("%d", &n);
+	for (int i = 0; i < n; ++i) {
+		scanf("%d %d %d", &b, &j, &k);
+		if (b)
+			printf("%c -> $\n", 'S' + i);
+		printf("%c -> 0%c\n%c -> 1%c\n", i+83, j+83, i+83, k+83);
+	}
+
+	return 0;
+}