Notice
Recent Posts
Recent Comments
Link
«   2025/09   »
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
Archives
Today
Total
관리 메뉴

히히

4406. 모음이 보이지 않는 사람 본문

study/SWEP

4406. 모음이 보이지 않는 사람

noun. 2018. 11. 20. 01:58

https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWNcD_66pUEDFAV8&categoryId=AWNcD_66pUEDFAV8&categoryType=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
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
 
 
int main() {
    int test_case;
    int T;
    string input;
    cin >> T;
 
    for (test_case = 1; test_case <= T; ++test_case) {
 
        cin >> input;
        cout << "#" << test_case << " ";
        for (int i = 0; i < input.size(); i++) {
            if (input[i] == 'a' || input[i] == 'e' || input[i] == 'i' || input[i] == 'o' || input[i] == 'u') {
                continue;
            }
            else {
                cout << input[i];
            }
        }
        cout << endl;
    }
}
cs


문자열.. 배열과 같음.. 인덱스.. 사용 가능...

진짜 간단한 문제를...

또 벡터 써보려고 안간힘 쓰다가 시간낭비 함... 배열에 문자열 넣어주고, 그걸 또 하나씩 벡터에 넣는 수고를 굳이 함..ㅎ

그러면서 굳이 모음 있는건 erase로 지우고 출력하려 함 ㅋㅋㅋㅋㅋㅋ 그러니까 자꾸 

vector subscript out of range ...이런 에러 뜨고.. 

erase 쓰려고 iterator 쓰니까 vector erase iterator outside range 이런

에러도 뜨고 ㅎㅎㅎ... 디버깅 하고나서 다 에러 잡긴 했지만.. 그래 그래도

이런 에러를 통해 벡터에 대해 더 잘 알게 되는 계기가 되었다 ...ㅠ

'study > SWEP' 카테고리의 다른 글

3456. 직사각형 길이 찾기  (0) 2018.11.20
3750. Digit sum  (0) 2018.11.20
5789. 현주의 상자 바꾸기  (0) 2018.11.19
5549. 홀수일까 짝수일까  (0) 2018.11.19
4299. 태혁이의 사랑은 타이밍  (0) 2018.11.19
Comments