杭电1283 http://acm.hdu.edu.cn/showproblem.php?pid=1283
题目大意:阅读理解。
AC代码:
#include<iostream>
#include<cstring>
using namespace std;
char a[205];
int m1,m2;
int r1,r2,r3;
int main() {
while(cin >> m1 >> m2) {
r1 = 0,r2 = 0, r3 = 0;
memset(a,0,sizeof(a));
cin >> a;
int len = strlen(a);
for(int i = 0;i < len; i++) {
switch(a[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;
}
}
cout << m1 << "," << m2 <<endl;
}
return 0;
}