U E D R , A S I H C RSS

데블스캠프2006/화요일/pointer/문제4/성우용

팰린드롬
~cpp
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
	int i,n;
	char buf[64];
	char buf_[64];
	cout<<"문자를 입력하세요.";
	cin>>buf;
	int length = strlen(buf);
	for (i=0;i<length;i++)
	buf_[i] = buf[length-i-1];
	buf_[length] = '\0';
	
	for (i=0;i<length;i++)
	{
		if (buf[i] != buf_[i]){
		cout<<"false";
		cout<<"\n";
		return 0;
		}
	}
	cout<<"true";
	cout<<"\n";
	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2009-05-27 07:09:19
Processing time 0.0098 sec