|Online Judge||Problem Set||Authors||Online Contests||User|
BF is a language that was designed to challenge and amuse programmers. BF uses a simple machine model consisting, besides the program, of:
In this problem you are asked to implement a BF interpreter, your program should read a BF program and an input stream and should print the output stream.
BF syntax is easy, only the following commands are available:
The given BF programs will be syntactically valid also the ‘>’ and ‘<’ operators will never lead to a value outside range [0-30000].
Input starts with the number of test cases on a line by itself. Then a number of test cases; each test case is formatted as follows.
A test case may span on multiple lines and each two consecutive test cases are separated by a blank line.
The embedded text could be any characters except the dollar sign terminator, you should ONLY process the 8 commands and detect the end of program/input by the dollar signs, discard any other characters when processing. In the sample input only the relevant input is underlined, however in the real test cases there will be no signs of input termination except for the dollar signs.
Output should be “Case “ then test case number (starting with 1) , a colon, a space followed by the contents of the BF program output stream and a new line after each test case.
3 ,>,>,>,.<.<.<. $ abcde $ This is a sample BF program ,>++++++[<-------->-],[<+>-]<. That Prints the summation of 2 numbers $ 23 $ ,>,> ++++[<++++++++>-]<. >++++[<<++++++++>>-]<<. Adds to every cell 8*4=32 and prints 'em in reverse order $ AB $
Case 1: dcba Case 2: 5 Case 3: ba
[Submit] [Go Back] [Status] [Discuss]
Home Page Go Back To top
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator