当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2314:POJ language

题目描述
The problem wants you to understand a new programming language, POJ language, and ask you to calculate the result of a program, which is written in this language.

The language may be described as follow (the integers mentioned here are in [-231, 231)):
  1. The syntax of this language is similar with C language, but much more simple. And the different will be mentioned as below.
  2. The length of a program written in the language will not exceed 1000 letters.
  3. The variables need not declaration. If a variable is first mentioned, the value of the variable is set to be 0. And once a variable is mentioned, it will have a global scope. The length of the name of a variable will not exceed 5.
  4. A Boolean expression has the structures: "A<B", "A==B" and "A<=B", here A is a variable or an integer, and so is B.
  5. There are three kind of normal expression I, II and III.
  6. The Normal expression I has one of the follow structures: "A=B;", "A=B+C;", "A=B-C;" and "A=B*C;", here A is an variable, B is an variable or a positive integer and C is also an variable or a positive integer. It's confirmed that the new value of A is also in [-231, 231). And it's assumed that a program will execute these expressions at most 100000 times before terminated.
  7. In the language there is a new expression that is not defined in C language, and we consider this expression as normal expression II. The expression is as: "#A;", here A is a variable. This expression terminates the program and gives the result of the program, and it is the only way to terminate a program. And it's confirmed that during the processing of the program it must meet this expression.
  8. There are only two key words in the language, "if" and "while". There kinds of structures are considered as normal expression III.
    a) The "if" sentence is as: "if(a Boolean expression){some normal expressions}".
    b) The "while" sentence is as: "while(a Boolean expression){some normal expressions}".

  9. There may be white spaces, which includes " ", "\t" and "\n", at any position except in key words, Boolean expressions, normal expressions I and normal expressions II.
  10. The program consists of some normal expressions.

输入解释
The input contains a program written in the POJ language.
输出解释
The output contains an integer, which is the result of the program.
输入样例
aaaaa=2;

bbb=5;

while ( aaaaa<=bbb ) {
	if(ccc<10){
		ccc=ccc+aaaaa;
		}
	bbb=bbb-1;

	if(100
                                
输出样例
8

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 POJ Monthly,kicc

源链接: POJ-2314

最后修改于 2020-10-29T06:29:34+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536