题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1283
按题目要求直接模拟即可。
#include <stdio.h>
int main(void)
{
int M1, M2, R1, R2, R3;
char ch;
while (scanf("%d%d", &M1, &M2) != EOF) {
getchar();
R1 = R2 = R3 = 0;
while ((ch = getchar()) != '\n') {
if (ch == 'A')
R1 = M1;
else if (ch == 'B')
R2 = M2;
else if (ch == 'C')
M1 = R3;
else if (ch == 'D')
M2 = R3;
else if (ch == 'E')
R3 = R1 + R2;
else if (ch == 'F')
R3 = R1 - R2;
}
printf("%d,%d\n", M1, M2);
}
return 0;
}