#include <string>
#include <vector>
using namespace std;
string solution(string my_string, int num1, int num2) {
string answer = "";
for(int i =0; i<my_string.size();i++)
{
if(i==num1)
answer.push_back(my_string[num2]);
else if(i==num2)
answer.push_back(my_string[num1]);
else
answer.push_back(my_string[i]);
}
return answer;
}
문제풀이:
'코딩테스트' 카테고리의 다른 글
프로그래머스_0단계_순서 바꾸기 C++ (0) | 2024.04.25 |
---|---|
프로그래머스_0단계_배열의 길이에 따라 다른 연산하기 C++ (0) | 2024.04.25 |
프로그래머스_1단계_콜라츠 추측 C++ (0) | 2024.04.23 |
프로그래머스_1단계_약수의 합 C++ (0) | 2024.04.23 |
프로그래머스_0단계_첫 번째로 나오는 음수 C++ (0) | 2024.04.23 |