-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11.cpp
42 lines (37 loc) · 796 Bytes
/
11.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <fstream>
#include <list>
#include <sstream>
using namespace std;
list<string>code;
int main(){
fstream fin("input1");
string line;
while(getline(fin,line)){
stringstream s(line);
string el;
while(getline(s,el,' ')){
code.push_back(el);
}
string first=code.front();
code.pop_front();
code.pop_front();
string second=code.front();
code.pop_front();
cout<<"MOV "<<first<<","<<second<<endl;
if(!code.empty()){
string pstring=code.front();
code.pop_front();
if(pstring=="+")
cout<<"ADD "<<first<<",";
else if(pstring=="-")
cout<<"SUB "<<first<<",";
else if(pstring=="*")
cout<<"MUL "<<first<<",";
else if(pstring=="/")
cout<<"DIV "<<first<<",";
cout<<code.front()<<endl;
code.pop_front();
}
}
}