U E D R , A S I H C RSS

인터프리터/권정욱

인터프리너/권정욱


미완성
~cpp 
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;

int main(){
	string num[100];
	int array = 0;
	int temp1 = 0;
	int temp2 = 0;
	ifstream fin("인터프리터.txt");
	ofstream fout("인터프리터결과.txt");
	
	for (int i =0; i<100; i++){
		num[i] = "000";
	}
	while(!fin.eof()){
		string instruction;
		fin >> instruction;
		if (instruction[0] != '*') {
			num[array] = instruction;
			array++;
		}
		else array = atoi(instruction.substr(1, 2).c_str());
	}

	array = 0;

	while(num[array] != "000"){
		if (num[array] == "901") {
			cout << "입력 : ";
			cin >> temp1;
		}
		else if (num[array] == "902")
			cout << "출력 : " << temp1;
		else if (num[array] == "000") break;
		else if (num[array][1] == '1') {
			temp2 = num[array].substr(1,2).c_str());
			temp1 += temp2;
		}
		else if (num[array][1] == '2') {
			temp2 = num[array].substr(1,2).c_str());
			temp1 -= temp2;
		}
		else if (num[array][1] == '3') {
			temp2 = num[array].substr(1,2).c_str());
			temp1 += temp2;
		}
		else if (num[array][1] == '5') {
			temp2 = num[array].substr(1,2).c_str());
			temp1 += temp2;
		}
	}
	for (i = 0; i< 100; i++){
		cout << instruction[i];
		if ((i%10) == 0) cout << endl;
	}
	return 0;
}

상머신만들기
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:30:35
Processing time 0.0076 sec