공부 자료/알고리즘
(C/C++) 백준 2711번 - 오타맨 고창영
뚜루뚜루세니
2021. 7. 5. 20:15
728x90
문제출처:https://www.acmicpc.net/group/practice/1801/486
1. 코드
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
char arr[100];
for (int i = 0; i < n; i++) {
int wrong;
scanf("%d %s", &wrong, arr);
for (int j = 0; j < strlen(arr); j++) {
if (j != wrong - 1) {
printf("%c", arr[j]);
}
}
printf("\n");
}
}
2. 해결 과정
문자열을 입력 받고 빼야할 인덱스 값을 제외하고 문자를 출력해준다.
3. 느낀점
처음에 배열 안 내용을 어떻게 삭제할까 고민을 했는데 그냥 한 글자씩 출력하면 되는 걸루
728x90