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
- 10773
- 전자책
- c++
- 백준
- 2941
- LJESNJAK
- 브런치
- BAKA
- Parenthesis
- QA
- process control
- 균형잡힌 세상
- system programming
- File 조작
- 5622
- Process Communication
- For Beginners
- c
- 시스템 프로그래밍
- Zero That Out
- file IO
- 시프
- IT
- 입력 버퍼
- 해바
- Baekjoon
- 바샤
- 1874
- The Balance of the World
- 4949
Archives
- Today
- Total
해바
2675) 7. 문자열 : 문자열 반복(Repeating Characters) 본문
문제
https://www.acmicpc.net/problem/2675
2675번: 문자열 반복
문제 문자열 S를 입력받은 후에, 각 문자를 R번 반복해 새 문자열 P를 만든 후 출력하는 프로그램을 작성하시오. 즉, 첫 번째 문자를 R번 반복하고, 두 번째 문자를 R번 반복하는 식으로 P를 만들면 된다. S에는 QR Code "alphanumeric" 문자만 들어있다. QR Code "alphanumeric" 문자는 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\$%*+-./: 이다. 입력 첫째 줄에 테스트 케이스의 개수 T(1
www.acmicpc.net
풀이
#include "cstdio"
#include "vector"
int main() {
int count(0), repeat(0);
char str('\0');
std::vector< std::vector<char> > arr; // 이차원 벡터
scanf("%d", &count);
for(int i(0); i < count; i++) {
str = '\0';
std::vector<char> temp;
scanf("%d ", &repeat);
while(str != '\n') {
str = getchar();
for(int j(0); str != '\n' && j < repeat; j++) temp.push_back(str);
}
arr.push_back(temp); // 이러면 한줄 추가
}
for(int i(0); i < count; i++) {
for(int j(0); j < arr[i].size(); j++) printf("%c", arr[i][j]);
puts("");
}
arr.clear();
return 0;
}
'C, C++' 카테고리의 다른 글
1152) 7. 문자열 : 단어의 개수 (0) | 2019.08.14 |
---|---|
1157) 7. 문자열 : 단어 공부 (0) | 2019.08.14 |
10809) 7. 문자열 : 알파벳 찾기 (0) | 2019.08.12 |
11720) 7. 문자열 : 숫자의 합 (0) | 2019.08.12 |
2447) 6. 함수 : 별 찍기 - 10 (0) | 2019.08.11 |
Comments