알고리즘/백준 알고리즘

2675-문자열 반복

TIM_0529 2022. 12. 25. 13:25
반응형
#include <iostream>
using namespace std;

void Repeating_String_C() {
	string words;
	int size;
	int repeat;
	cin >> repeat;
	while (repeat>0)
	{
		cin >> size >> words;
		for (int i = 0; i < words.size(); i++)
		{
			for (int j = 0; j < size; j++)
			{
				cout << words[i];
			}
		}
		cout << endl;
		--repeat;
	}
}
int main() {
	Repeating_String_C();
}

2024데이터 사용

다른 사람에 코드 

int main() {

	int t, n;
	char c;
	scanf("%d", &t);
	while (t--) {
		scanf("%d ", &n);
		for (;;) 
		{
			scanf("%c", &c);
			if (c == '\n') { printf("\n"); break; }
			for (int i = 0; i < n; ++i)printf("%c", c);
		}
	}
}

1112 사용

반응형

'알고리즘 > 백준 알고리즘' 카테고리의 다른 글

2908 - 상수  (2) 2022.12.28
1157-단어공부 c++  (0) 2022.12.26
10809-알파벳 찾기  (2) 2022.12.24
11720 - 숫자의 합  (0) 2022.12.24
11654-아스키 코드  (0) 2022.12.24