본문 바로가기
Computer Science

세상의 모든 팰린드롬 2

by OKOK 2019. 2. 13.

1. 오케이

2. 앞과 뒤에서 한칵씩 접근하기

3. 생각나는 설계 풀이 그대로 풀이하기


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
35
36
37
38
39
40
41
#include <stdio.h>
 
char data[21];
int main()
{
    freopen("input.txt""r", stdin);
    int tc;
    scanf("%d"&tc);
    while(tc--)
    { 
        scanf("%s", data);
        int l = 0;
        int sw = 1;
        while (data[++l] != '\0');
        int j = l - 1;
        int i = 0;
 
        while (i < l / 2)
        {
            if (data[i] != data[j]) // 뒤와 앞에서 하나씩 시작해서
            {
                if (data[i] == '*' || data[j] == '*'// *가 있으면 통과
                {
                    sw = 1;
                    break;
                }
                else {
                    sw = 0;
                    break;
                }
            }
            i++;
            j--;
        }
        if (sw)
            printf("Exist\n");
        else
            printf("Not exist\n");
    }
    return 0;
}
cs

 


'Computer Science' 카테고리의 다른 글

모음이 보이지 않는 사람  (0) 2019.02.13
세상의 모든 팰린드롬  (0) 2019.02.13
초콜릿과 건포도  (0) 2019.02.12
석찬이의 받아쓰기  (0) 2019.02.12
배열의 분할  (0) 2019.02.12

댓글