现在的位置: 首页 > 综合 > 正文

模拟解hdu1283 最简单的计算机

2019年11月07日 ⁄ 综合 ⁄ 共 486字 ⁄ 字号 评论关闭
#include<iostream>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
int r[10],m[10],n;
string s; 
int main()
{
	while(cin>>m[1]>>m[2])
	{
		cin>>s;
		n=s.length();
		memset(r,0,sizeof(r));
		for(int i=0;i<n;i++)
		{
			if(s[i]=='A')
				r[1]=m[1];
			else if(s[i]=='B')
				r[2]=m[2];
			else if(s[i]=='C')
				m[1]=r[3];
			else if(s[i]=='D')
				m[2]=r[3];
			else if(s[i]=='E')
				r[3]=r[1]+r[2];
			else
				r[3]=r[1]-r[2];
		}
		printf("%d,%d\n",m[1],m[2]);
	}
}

抱歉!评论已关闭.