简单模拟题。
CODE:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
using namespace std;
const int maxn = 201;
int M1, M2, R1, R2, R3;
char s[maxn];
int main()
{
while(~scanf("%d%d", &M1, &M2))
{
int i, j;
R1 = R2 = R3 = 0;
scanf("%s", s);
int l = strlen(s);
for(i = 0; i < l; i++)
{
char c = s[i];
switch(c)
{
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;
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
using namespace std;
const int maxn = 201;
int M1, M2, R1, R2, R3;
char s[maxn];
int main()
{
while(~scanf("%d%d", &M1, &M2))
{
int i, j;
R1 = R2 = R3 = 0;
scanf("%s", s);
int l = strlen(s);
for(i = 0; i < l; i++)
{
char c = s[i];
switch(c)
{
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;
}