How We Coding

### 전체탐색 ###

### SRM428 Div2 Level 1 ###



<소스코드>


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <string>
using namespace std;
 
class ThePalindrome {
public:
    bool isP(char *str, int s, int e) {
        if(s >= e) return 1;
        return str[s]==str[e] ? isP(str, s+1, e-1) : 0;
    }
    int find(string s) {
        char str[101]={0};
        int size = s.size();
        for(int i=0; i<size; i++)
            str[i] = s[i];
        for(int i=0; i<size; i++) {
            if(isP(str, 0size-1+i)) return size+i;
            for(int j=0; j<=i; j++) {
                str[size+i-j] = str[j];
            }
        }
        return size*2-1;
    }
};
 
cs