No older revisions available
No older revisions available
== 팰린드롬 ==
~cpp #include<iostream> using namespace std; bool reverse(char a[],int lengh){ char *b = new char[lengh+1]; for(int i=0; i<lengh; i++) b[i] = a[lengh-i-1]; b[lengh] = a[lengh]; for(i=0;i<lengh;i++) if(!(a[i] == b[i])) return false; delete [] b; return true; } void main(){ int i=0,lengh=0; char *a = new char[256]; cin >> a; while(a[i++] != '\0') { lengh++; } cout << lengh << endl; if(reverse(a,lengh)) cout << a << "는 팰린드롬입니다" << endl; else cout << a << "는 팰린드롬이 아닙니다" << endl; delete [] a; }