1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#include <stdio.h> #include <string.h> void main() { char *tango_list[][2] = { { "dog", "inu" }, { "house", "ie" }, { "roof", "yane" }, { "mountain", "yama" }, { "river", "kawa" }, }; char ans[20], buf[20]; for (int i = 0; i < 5; i++) { printf("%s = ", tango_list[i][0]); fgets(buf, 20, stdin); sscanf(buf, "%s", ans); printf("%s\n", (strcmp(ans, tango_list[i][1]) == 0) ? "atari" : "hazure"); } }