Skip to content

Commit

Permalink
이슈 #371에서 솔루션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 21, 2024
1 parent 2fda1e6 commit f362672
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Programmers/문자열_계산하기.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <string>
#include <vector>
#include <sstream>

using namespace std;

int solution(string my_string) {
stringstream ss(my_string);
int result;
ss >> result;

char op;
int number;

while(ss >> op >> number) {
if(op == '+') result += number;
else if(op == '-') result -= number;
}

return result;
}

0 comments on commit f362672

Please sign in to comment.