U E D R , A S I H C RSS

데블스캠프2006/화요일/pointer/문제4/김준석

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; 
}

데블스캠프2006/화요일/pointer
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:07
Processing time 0.0183 sec