https://www.acmicpc.net/problem/13163
13163번: 닉네임에 갓 붙이기
첫 번째 줄에는 닉네임의 수 N(1 ≤ N ≤ 100)이 주어진다. 두 번째 줄부터 N개의 줄에는 음절 단위로 쪼갠 닉네임이 주어진다. 각 줄은 알파벳 소문자와 공백만으로 이루어지며, 쪼갠 닉네임의 총 길이(공백 포함)는 100을 넘지 않는다. 쪼갠 닉네임에는 1개 이상의 공백이 존재한다.
www.acmicpc.net
한줄 후기 : 오호랏 godchae~


쉽다.
#include <stdio.h>
#include <string.h>
int change(int cnt, char str[]);
int main(){
char str[102];
int n, i, cnt;
scanf("%d\n", &n);
for(i=0; i<n; i++){
cnt=0;
gets(str);
change(cnt, str);
}
}
int change(int cnt, char str[]){
char arr[102] = {0};
int i, j=0;
for(i=0; i<strlen(str); i++){
if(cnt == 0){
if(str[i] == ' ') cnt++;
}
else{
if(str[i] != ' ') arr[j++] = str[i];
}
}
printf("god%s\n",arr);
return;
}
'DEV > PS' 카테고리의 다른 글
[9933] 민균이의 비밀번호, C (0) | 2019.07.20 |
---|---|
[15953] 상금 헌터, C (0) | 2019.07.15 |
[1713] 후보 추천하기, C (0) | 2019.07.15 |
[15904] UCPC는 무엇의 약자일까? , C (0) | 2019.07.05 |
[2841] 외계인의 기타연주, C (0) | 2019.07.04 |