📄 2398780_ac_0ms_68k.cpp
字号:
#include <stdio.h>
#include <string.h>
#include <math.h>
char Exp[300];
bool var[6];
bool cal(char str[])
{
int i, n1, n2;
char t1[300], t2[300];
if(strlen(str)==1)
return var[str[0]-'p'];
if(str[0]=='N')
return !cal(&str[1]);
n1 = 0;n2 = 0;
for(i = 1; str[i]!='\0'; i++)
{
if(str[i]=='N')
continue;
if(str[i]<='Z')
n1++;
else
n2++;
if(n1+1==n2)
break;
}
strcpy(t2,&str[i+1]);
str[i+1] = '\0';
strcpy(t1,&str[1]);
if(str[0]=='K')
return cal(t1)&&cal(t2);
if(str[0]=='A')
return cal(t1)||cal(t2);
if(str[0]=='E')
return cal(t1)==cal(t2);
return (cal(t1)==0)||cal(t2);
}
void solve()
{
int i, j;
char Tmp[300];
for(i = 0; i < 32; i++)
{
for(j = 0; j < 5; j++)
var[j] = (i&(1<<j))!=0;
strcpy(Tmp,Exp);
if(!cal(Tmp))
{
printf("not\n");
return ;
}
}
printf("tautology\n");
}
int main()
{
while(scanf("%s",Exp)==1&&Exp[0]!='0')
solve();
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -