题目描述

数据范围

解法

模拟。

代码

#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<iostream>
#define ll long long
using namespace std;
const char* fin="form.in";
const char* fout="form.out";
const int inf=0x7fffffff;
const int maxn=40007;
char ch;
bool stack[maxn];
int t,tot,y;
int main(){
freopen(fin,"r",stdin);
freopen(fout,"w",stdout);
ch=getchar();
while (1){
y=0;
while (ch!='(' && ch!=')' && ch!='F' && ch!='T'){
ch=getchar();
y++;
if (y==10) return 0;
}
t++;
tot=0;
stack[tot]=false;
while (ch=='(' || ch==')' || ch=='F' || ch=='T'){
if (ch=='('){
tot++;
stack[tot]=(tot&1?true:false);
}else if (ch==')'){
if (tot&1) stack[tot-1]|=stack[tot];
else stack[tot-1]&=stack[tot];
tot--;
}else if (ch=='F'){
if (tot%2) stack[tot]=false;
}else if (tot%2==0) stack[tot]=true;
ch=getchar();
}
if (stack[0]) printf("%d. true\n",t);
else printf("%d. false\n",t);
}
return 0;
}

启发

利用getchar()连续多次失效来判断文件输入结束。

最新文章

  1. SVN需要忽略的文件类型
  2. SpringMVC介绍之Validation
  3. http://blog.csdn.net/liuqinstudy/article/details/8281498
  4. 2016年10月13日 星期四 --出埃及记 Exodus 18:24
  5. MySQL5.7.13源码编译安装指南(转)
  6. 2017年浙江理工大学程序设计竞赛校赛 题解&amp;源码(A.水, D. 简单贪心 ,E.数论,I 暴力)
  7. Imcash:一边大裁员,一边大扩招,你能否成为区块链人才中的7%?
  8. Docker 启动,进入容器,查看log命令
  9. 蒟阵P3390 【模板】矩阵快速幂
  10. LeetCode169 求众数
  11. Java学习08 (第一遍) - SpringMVC
  12. KD-树(下)
  13. Selenium2+python自动化73-定位的坑:class属性有空格
  14. Python笔记:Python中is和==的区别
  15. 20155218《网络对抗》Exp3 免杀原理与实践
  16. 慕课网价值149《前端JavaScript面试技巧》笔记大公开——适应群体(学生或应届毕业生)
  17. unity3d 材质概述 ---- shader
  18. JNative用法注意事项
  19. 基于aop的redis自动缓存实现
  20. (一)mvc与mvvm设计模式

热门文章

  1. IDEA常用插件整理
  2. Spring cloud properties与yml配置说明
  3. 2019.10.26 csp-s模拟测试88 反思总结
  4. LA3882 And Then There Was One
  5. Javascript-new Date() 与 Date() 的区别
  6. 洛谷 P3956 棋盘
  7. [Array]414. Third Maximum Number
  8. pc端拖拽
  9. node学习记录——搭建web服务器
  10. warning: deprecated conversion from string constant to &#39;char*