728x90
반응형
stoi() 함수를 사용해서 바꿔주는 것으로 문제를 풀었다.
#include <string>
#include <vector>
using namespace std;
int solution(string s) {
int answer = 0;
answer = stoi(s);
return answer;
}
프로그래머스 C++ Level. 0 문자열로 변환
정수 n이 주어질 때, n을 문자열로 변환하여 return하도록 solution 함수를 완성해주세요. #include #include using namespace std; string solution(int n) { string answer = ""; answer = to_string(n); return answer; } 프로그래머스
yeni-0224.tistory.com
이 글을 참고하기!
728x90
반응형
'프로그래머스 C++ > Level.1' 카테고리의 다른 글
프로그래머스 Level.1 하샤드 수 (0) | 2023.08.21 |
---|---|
프로그래머스 Level1. 정수 내림차순으로 배치하기 (0) | 2023.08.20 |
프로그래머스 Level.1 자연수 뒤집어 배열로 만들기 (0) | 2023.07.10 |
프로그래머스 Level.1 문자열 내 p와 y의 개수 (0) | 2023.07.08 |
프로그래머스 Level.1 나누어 떨어지는 숫자 배열 (0) | 2023.07.07 |