#include<string.h>
#include <stdio.h>
#include <stdlib.h>
#include<stdbool.h>
int main(void)
{
const char* str1 = "too high";
const char* str2 = "too low";
const char* str3 = "right on";
bool honest = true;
int table[11] = { 0 };
int n = 0;
char input[10] = { '\0' };
while (scanf("%d", &n) && n!=0)
{
getchar();
gets_s(input);
if (!strcmp(input, str3))
{
honest = true;
for (int i = 1; i < 10; i++)
{
if (n > i && table[i]==3)
{
honest = false;
}
else if (n < i && table[i] == 1)
{
honest = false;
}
}
if (honest)
{
printf("Stan may be honest\n");
}
else { printf("Stan is dishonest\n"); }
memset(table, 0, sizeof(table));
}
else if (!strcmp(input, str1))// == "too high")
{
table[n] = 3;
}
else if (!strcmp(input, str2))// == "too low")
{
table[n] = 1;
}
}
return 0;
}
利用table存 "大" "小"
來判斷他是否說謊