카테고리 없음

[프로그래머스][Level1] 문자열을 정수로 바꾸기 c++

박빵이 2022. 9. 2. 01:29

 

풀이과정

문자열을 숫자로 바꿔주는 가장 기본적인 문제다.  
만약 int로 바꿔줘야 한다면 stoi함수를 쓰고,  
long long으로 바꿔줘야 한다면 stoll함수를 쓰면 된다.

 

#include <string>
#include <vector>

using namespace std;

int solution(string s) {
    int answer = 0;
    answer = stoi(s);
    return answer;
}