카테고리 없음
[프로그래머스][Level1] 문자열을 정수로 바꾸기 c++
박빵이
2022. 9. 2. 01:29
https://school.programmers.co.kr/learn/courses/30/lessons/12925
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
풀이과정
문자열을 숫자로 바꿔주는 가장 기본적인 문제다.
만약 int로 바꿔줘야 한다면 stoi함수를 쓰고,
long long으로 바꿔줘야 한다면 stoll함수를 쓰면 된다.
#include <string>
#include <vector>
using namespace std;
int solution(string s) {
int answer = 0;
answer = stoi(s);
return answer;
}