【习题 5-9 UVA - 1596】Bug Hunt】的更多相关文章

In this problem, we consider a simple programming language that has only declarations of onedimensional integer arrays and assignment statements. The problem is to find a bug in the given program. The syntax of this language is given in BNF as follow…
In this problem, we consider a simple programming language that has only declarations of one-dimensional integer arrays and assignment statements. The problem is to find a bug in the given program. The syntax of this language is given in BNF as follo…
题意: 输入并模拟执行一段程序,输出第一个bug所在的行. 每行程序有两种可能: 数组定义: 格式为arr[size]. 例如a[10]或者b[5],可用下标分别是0-9和0-4.定义之后所有元素均为未初始化状态. 赋值语句: 格式为arr[index]=value. 或者arr[index] = arr[arr[index]]. 例如a[0]=3或者a[a[0]]=a[1]. 赋值语句和数组定义可能会出现两种bug: 下标index越界: 使用未初始化的变量(index和value都可 能出现…
题意 : 给出几组由数组定义与赋值构成的编程语句, 有可能有两种BUG, 第一种为数组下标越界, 第二种为使用尚未定义的数组元素, 叫你找出最早出现BUG的一行并输出, 每组以' . '号分隔, 当有两组输入都是' . '时结束程序 分析 : 由于错误的类型由题意所述的两种组成, 所以我们需要知道每个数组的长度与每个已经被赋值定义过的数组元素大小, 因此可以定义map<string, int> Info 来存储数组名和这个数组的大小两个信息, 在定义一个map<string, map&l…
题意:给定两种操作,一种是定义一个数组,另一种是赋值,让你找出哪一步时出错了,出错只有两种,一种是数组越界,另一种是访问未定义变量. 析:当初看到这个题时,感觉好麻烦啊,然后就放过去了,而现在要重新回来做一下,感觉也不好做,做了1个多小时..... 现在分析一下是思路,我觉得我想的比较麻烦,我首先定义了两个map,分别是数组的最大长度和数组的,赋值情况,然后用向量把所有操作存起来, 在定义时很简单,直接把长度赋给map就行,麻烦就是在这个赋值时,首先是把等号两边的分开,先计算等号右边的操作,主要…
题目 题目     分析 算是个模拟吧     代码 #include <bits/stdc++.h> using namespace std; map<int,int> a[130]; char s[85]; int n[130]; int PosIs() { int len=strlen(s); for(int i=0;i<len;i++) if(s[i]=='=') return i; return -1; } int get_num(int k) { int res=…
//开学了,好烦啊啊啊啊啊!怎么开个学那么多破事情!!都俩星期了,终于有时间写出来一道题 题意:不难理解,不写了.这几天忙的心累. 代码:(Accepted, 0.010s) //UVa1596 - Bug Hunt #include<iostream> #include<sstream> #include<string> #include<stack> #include<map> using namespace std; struct o_O…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] map模拟 map<string,int>记录每个数组的大小 map <pair<string, int> ,int>记录数组的某个下标的值. 递归处理嵌套的情况就好 [代码] #include <bits/stdc++.h> using namespace std; string s; map <string, int> mmap; map <pair<string…
  In this problem, we consider a simple programming language that has only declarations of onedimensional integer arrays and assignment statements. The problem is to find a bug in the given program. The syntax of this language is given in BNF as foll…
ACM训练计划建议 From:freecode#  Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜鸟之作,大牛勿喷,如有不当或补充之处,欢迎指出. 本建议书分为三个阶段,大一.大二.大三.大四暂没整理,一方面是大四要面临考验和找工作的问题,坚持继续acm的很少,另一方面,本人还没大四…… 下面以个人经验分析一下这三个阶段建议学习的内容和具体的训练计划. 正文: 大一(第一阶段): 大一是时间最充…