# HDU 1283 simplest computer

Source: Internet
Author: User

Description

A research organization named pigheadthree designed a computer for experiment named PPMM. PPMM can only execute six simple commands a, B, c, d, e, f; only two memory M1, M2; three registers R1, R2, R3. The meaning of the six commands is as follows:
Command A: load the data of memory M1 to register R1;
Command B: load the data in memory m2 to register R2;
Command C: load the data in register R3 to memory M1;
Command D: load the data in register R3 to memory m2;
Command E: add the data in register R1 to the data in register R2. The result is put into Register R3;
Command F: subtract the data in register R1 from the data in register R2 and put the result in register R3.

Input

There are several groups, each group has two rows, the first row is two integers, representing the initial content in M1 and M2 respectively; the second line is a string of commands from uppercase letters A to F with a length not greater than 200. The meaning of the command string is described above.

Output

For each input group, there is only one output line and two integers, representing the content of M1 and M2 respectively. m1 and m2 are separated by commas.

Others: the initial values of R1, R2, and R3 are 0, and all intermediate results are between-2 ^ 31 and 2 ^ 31.

Sample Input

`100 288ABECED876356 321456ABECAEDBECAF`

Sample output

`388,3882717080,1519268#include<iostream>#include<cstdio>using namespace std;struct computer{    int m1,m2,r1,r2,r3;    computer(int x,int y):m1(x),m2(y),r1(0),r2(0),r3(0) {}    void a(){r1=m1;}    void b(){r2=m2;}    void c(){m1=r3;}    void d(){m2=r3;}    void e(){r3=r1+r2;}    void f(){r3=r1-r2;}};int main(){    //freopen("in.txt","r",stdin);    int x,y;    char order[210];    while(scanf("%d%d",&x,&y)!=EOF)    {        computer com(x,y);        scanf("%s",order);        for(int i=0;order[i];i++)        {            switch(order[i])            {                case 'A':com.a();break;                case 'B':com.b();break;                case 'C':com.c();break;                case 'D':com.d();break;                case 'E':com.e();break;                case 'F':com.f();break;                default:break;            }        }        printf("%d,%d\n",com.m1,com.m2);    }    return 0;}`
Related Keywords:
Related Article

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.