http://acm.hdu.edu.cn/showproblem.php?pid=1283

模拟

View Code
#include <stdio.h>

int main() 
{
    int m1,m2,r1,r2,r3,i;
    char s[300];
    while(~scanf("%d%d",&m1,&m2)) 
    {
        scanf("%s",s);
        r1=r2=r3=0;
        for(i=0;s[i];i++) 
        {
               switch(s[i]) 
               {
                case 'A':r1=m1;break;
                case 'B':r2=m2;break;
                case 'C':m1=r3;break;
                case 'D':m2=r3;break;
                case 'E':r3=r1+r2;break;
                case 'F':r3=r1-r2;break;
            }
        }
        printf("%d,%d\n",m1,m2);
    }
    return 0;
}