https://school.programmers.co.kr/learn/courses/30/lessons/120892
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
#include <string>
#include <vector>
using namespace std;
string solution(string cipher, int code) {
string answer = "";
for(int i=code-1;i<cipher.length();i+=code)
{
answer+=cipher[i];
}
return answer;
}
설명
code번째 문자만을 골라내야하는 문제이다.
따라서 for문에 code-1 부터 i+=code 로 code번째 문자를 answer에 추가하면 된다.
'알고리즘 > 프로그래머스 1단계' 카테고리의 다른 글
프로그래머스 - 합성수 찾기 - C++ (0) | 2023.08.12 |
---|---|
프로그래머스 - 약수 구하기 - C++ (0) | 2023.08.11 |
프로그래머스 - 순서쌍의 개수 - C++ (0) | 2023.08.09 |
프로그래머스 - 옷가게 할인 받기 - C++ (0) | 2023.08.09 |
프로그래머스 - 정수를 나선형으로 배치하기 - C++ (0) | 2023.08.08 |