Q
백준 2675

C code
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 32 33 34
| #include <stdio.h> #include <string.h>
int main(void) { int t, r, count=0; char s[21] = ""; char p[20001] = "";
scanf("%d", &t);
if(t < 1 && t > 1000) return 0;
for(int i = 0; i < t; i++) { count = 0; scanf("%d %s", &r, s);
if(r < 1 && r > 8) return 0; if(strlen(s) < 1 && strlen(s) > 20) return 0;
for(int j = 0; j < strlen(s); j++) { for(int k = 0; k < r; k++) count += sprintf(p+count, "%c", s[j]); } printf("%s\n", p); }
return 0; }
|
Note
https://www.ibm.com/docs/ko/i/7.3?topic=functions-sprintf-print-formatted-data-buffer
Author:
Slay
Permalink:
http://sean-baek.github.io/2023/04/30/baekjoon-2675/
License:
Copyright (c) 2021 CC-BY-NC-4.0 LICENSE
Slogan:
Do you believe in DESTINY?