锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
緇欏嚭涓嬮潰鐨勬祴璇曟暟鎹?br>wa浜?嬈★紝灞呯劧鏄洜涓烘暟緇勮寖鍥存病鏈夋敞鎰忓埌錛佸洤鍥у洤銆?br>涓嬮潰鏄竴浜涙祴璇曟暟鎹?br>3 2
1 1 2
<
1 2 3
<
3 2
1 1 2
>
1 1 3
>
5 1
2 1 2 3 4
=
4 3
2 1 2 3 4
<
2 1 3 2 4
<
1 2 4
=
5 3
2 1 3 2 4
>
2 3 5 2 4
>
1 1 4
>
5 3
2 1 3 2 4
>
2 3 5 2 4
>
1 1 4
=
3 2
1 1 2
<
1 1 3
<
2 1
1 1 2
>
4 3
2 1 2 3 4
<
2 1 3 2 4
<
1 2 4
=
5 2
1 1 4
=
1 2 5
=
3 2
1 1 2
<
1 2 3
>
5 2
1 1 4
=
1 2 5
=
2 1
1 1 2
>
5 3
2 1 3 2 4
>
2 3 5 2 4
>
1 1 4
>
5 3
1 2 3
<
1 1 2
>
1 3 4
=
3 2
1 1 2
<
1 1 3
<
5 1
2 1 2 3 4
=
3 2
1 1 2
<
1 2 3
>
5 3
2 1 3 2 4
>
2 3 5 2 4
>
1 1 4
>
5 3
1 2 3
<
1 1 2
>
1 3 4
=
2 1
1 1 2
>
0 0
---
絳旀
Scenario #1:
0
Scenario #2:
1
Scenario #3:
5
Scenario #4:
1
Scenario #5:
4
Scenario #6:
0
Scenario #7:
1
Scenario #8:
0
Scenario #9:
1
Scenario #10:
3
Scenario #11:
2
Scenario #12:
3
Scenario #13:
0
Scenario #14:
4
Scenario #15:
2
Scenario #16:
1
Scenario #17:
5
Scenario #18:
2
Scenario #19:
4
Scenario #20:
2
Scenario #21:
0
The program counter holds the address of the instruction to be executed next. Each instruction has a length of 1 byte - the highest 3 bits define the type of instruction and the lowest 5 bits define an optional operand which is always a memory address (xxxxx). For instructions that don't need an operand the lowest 5 bits have no meaning (-----). Here is a list of the machine instructions and their semantics:
000xxxxx STA x store the value of the accu into memory byte x
001xxxxx LDA x load the value of memory byte x into the accu
010xxxxx BEQ x if the value of the accu is 0 load the value x into the pc
011----- NOP no operation
100----- DEC subtract 1 from the accu
101----- INC add 1 to the accu
110xxxxx JMP x load the value x into the pc
111----- HLT terminate program
In the beginning, program counter and accumulator are set to 0. After fetching an instruction but before its execution, the program counter is incremented. You can assume that programs will terminate.
00111110 10100000 01010000 11100000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00111111 10000000 00000010 11000010 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 11111111 10001001
10000111
5 1 -2 2 9 -1
0
涓嶇敤璧板叆鎺掑簭鐨勮鍖猴紝
鍙互鍦ㄧ嚎鎬х殑鏃墮棿鍐呭畬鎴愩?/pre>鍏堜竴瓚熷驚鐜紝淇濆瓨杈撳叆鐨勫糿[MAX],鍚屾椂鍙壘鍑烘渶灝忕殑鍊鹼紝鍐嶆潵涓瓚熷驚鐜互姝や負(fù)鍩哄噯瀵規(guī)瘡涓暟榪涜鏍囪錛屽姣忎釜鍑虹幇鐨刵um,mark[num-min]=1;鐒跺悗for(int i=0;;i++){if(mark[i]==0)cout<<i+min;break;} ----