Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- MySQL
- 토글 그룹
- mysqld.sock
- 알고리즘 목차
- 원형
- 마우스 따라다니기
- 백준
- 그리디알고리즘
- c#
- 단어 수학
- 탄막
- 18249
- 유니티
- 윈도우
- 탄막 이동
- 3273
- AI Hub
- 걷는건귀찮아
- 문자열 압축
- 강의실2
- 2020 KAKAO BLIND RECRUITMENT
- 회의실 배정
- 탄막 스킬 범위
- 영상 프레임 추출
- SWEA
- 자료구조 목차
- 우분투
- 알고리즘
- 3344
- 수 만들기
Archives
- Today
- Total
와이유스토리
[문자열] 프로그래머스 [3차] n진수 게임 C++ 본문
https://programmers.co.kr/learn/courses/30/lessons/17687
코딩테스트 연습 - [3차] n진수 게임
N진수 게임 튜브가 활동하는 코딩 동아리에서는 전통적으로 해오는 게임이 있다. 이 게임은 여러 사람이 둥글게 앉아서 숫자를 하나씩 차례대로 말하는 게임인데, 규칙은 다음과 같다. 숫자를 0
programmers.co.kr
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
string solution(int n, int t, int m, int p) {
char ch[16]={'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; // 저장해서 사용하기
string answer = "";
string str = "";
int num = 0;
while(str.length() < t*m) {
string temp = "";
int divider = num;
while(divider/n!=0) {
temp += ch[divider%n];
divider /= n;
}
temp+=ch[divider%n];
reverse(temp.begin(), temp.end());
str += temp;
cout << temp << " " ;
num++;
}
for(int i=p-1; ; i+=m) {
answer += str[i];
if(answer.length() == t) break;
}
return answer;
}
'코딩테스트 > 문자열' 카테고리의 다른 글
[딕셔너리] 프로그래머스 오픈채팅방 Python (0) | 2022.02.04 |
---|---|
[문자열] 프로그래머스 [1차] 뉴스 클러스터링 Python (0) | 2022.02.04 |
[딕셔너리] 프로그래머스 [3차] 압축 Python (0) | 2022.02.04 |
[문자열 변환] 프로그래머스 [3차] 방금그곡 Python (0) | 2022.02.04 |
[문자열 뒤집기] 프로그래머스 [1차] 비밀 지도 C++ (0) | 2022.02.04 |
Comments