#include<stdio.h> #include<string.h> int main() { char* str1[5] = {"reset", "board", "board", "reboot", "backplane"}; char* str2[5] = {"board", "add", "delete", "backplane", "abort"}; char str[100] = {0}; while (gets(str)) { int len = strlen(str); int flag = 0; int pos; for (int i = 0; i < len; i++) if (str[i] == ' ') { flag++; pos = i; } if (flag == 0) { char reset[20] = "reset"; if (strncmp(reset, str, len) == 0) printf("reset what\n"); else printf("unknown command\n"); } else if (flag == 1) { int count = 0; int result = 0; for (int i = 0; i < 5; i++) if (strncmp(str, str1[i], pos) == 0 && strncmp(str + pos + 1, str2[i], len - pos - 1) == 0) { count++; result = i; } if (count == 1) { if (result == 0) printf("board fault\n"); else if (result == 1) printf("where to add\n"); else if (result == 2) printf("no board at all\n"); else if (result == 3) printf("impossible\n"); else if (result == 4) printf("install first\n"); } else printf("unknown command\n"); } } return 0; }