[Help] Find greatly enlighten the meaning of this question

Category: C/C++ -> C Author: fanghongxi1025 Date: 2002-07-22 19:17:04
 
fanghongxi1025
2002-07-22 19:17:04
Background

has a special computer which has 10 registers and 1000-word memory. Each register and memory cell can store a 3-bit integer (0 ~ 999). The computer instructions are encoded as a 3-digit integer, and stored in memory. Instructions encoded meanings are as follows:

* 100 terminates

* 2dn will register d to n (0 ~ 9 between)

* 3dn register d to n and the value added and stored in the register in d

* 4dn d the n value in the register is multiplied and stored in register d in

* 5ds will register s values ​​assigned to register d

* 6ds will register the value s d add the values ​​in registers and stored in d in the register of the register

* 7ds s d value in the register and multiplies the values ​​stored in registers in d

* 8da the register referred to a memory address to read data into the register in d

* ; 9sa s data from the registers stored in the register referred to a memory address

* 0ds s nonzero if register on Jump to register the address referred to in d

starts, all registers are 000, and the memory of the data through the standard input is read. The computer begins execution from memory address 0, and the results of each instruction to be executed on the 1000 mod.

input

first line of input is a positive integer that represents the number of groups in the input data, each group has a blank line before the data .

each set of data up to 1000, which means that the memory address 0 from the value stored. No specific data is stored in memory to 0.

output

For each set of data, the output of the computer in the course of processing a total number of instructions (including termination command), you can assume that the program will eventually stop. The output between each set of results, have to add a blank line.

I have read five hours it. . This question is in the end still do not understand what to say. Register is variable it? For example int s, a, d; then these three variables are registers? There I am puzzled one is the output. There is a test case is such

2 ↵

299 ↵
492 ↵
495 ↵
399 ↵
492 ↵
495 ↵
399 ↵
283 ↵
279 ↵
689 ↵
078 ↵
100 ↵
000 ↵
000 ↵
000 ↵

100 ↵

I do not know why the first set of data given the answer is 16, if a row represents a row instructions, and 100 represents the end of the case, then it is only 12 rows of data belonging to the first group, then that is 12 instructions. . Halo. To collapse directly. . . .