리/ ¶
미
~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; }