The simplest computer problem description, a research organization called Pigheadthree, designed an experimental computer named PPMM. PPMM can only perform a simple six command a,b,c,d,e,f, only two memory m1,m2, and three registers of R1,R2,R3. The six commands have the following meanings:
Command A: Load the memory M1 data into the register R1;
Command b: Load the memory M2 data into the register R2;
Command c: Load the data of the register R3 into the memory M1;
Command d: Load the data of the register R3 into the memory M2;
Command e: The data in the register R1 and the data in the register R2 are added, and the result is placed in the Register R3;
Command f: Subtracts the data in the register R1 from the data in the register R2, and the result is placed in the register R3.
Your task is to design a program to simulate the operation of PPMM.
Input has several groups, each group has 2 rows, the first line is 2 integers, respectively, the initial content in M1 and M2, and the second line is a string of not more than 200 of the uppercase letters A to f consisting of a command string, the meaning of the command string as described above.
Output corresponds to each set of inputs, with only one row, two integers representing the contents of the m1,m2, where M1 and M2 are separated by commas.
Other notes: The initial value of R1,R2,R3 is 0, and all intermediate results are between -2^31 and 2^31.
Sample Input100 288abeced876356 321456ABECAEDBECAF Sample output388,3882717080,1519268
1#include <iostream>2#include <cstdio>3#include <cstring>4 using namespacestd;5 intMain ()6 {7 intm1,m2;8 while(cin>>m1>>M2)9 {Ten inti; One intr1=0, r2=0, r3=0; A GetChar (); - Chara[201]; - gets (a); the for(i=0; a[i]!=' /'; i++) - { - if(a[i]=='A') -r1=M1; + if(a[i]=='B') -R2=M2; + if(a[i]=='C') Am1=R3; at if(a[i]=='D') -M2=R3; - if(a[i]=='E') -r3=r1+R2; - if(a[i]=='F') -R3=r1-R2; in } -cout<<m1<<','<<M2<<Endl; to } +}
Computer Simulation (hd1283)