Thursday, February 10, 2011

My own finding all palendromes in a string

#include "iostream"
#include
using namespace std;

void prntstr(char *str,int j, int i)
{
while(j<=i) { cout << str[j]; j++; } cout << "\n"; } void isPalen(char* str, int pos) { int j =pos; int i = pos,count = 0; int k,l; for(i,j;(i<=11)&&(j>=0);i++,j--)
{
if(str[j] == str[i+1])
{
// cout << str[j] << " " << str[i+1] << "\n"; count++; k = j;l=i+1; } } // cout << count; if(count>0){
count = 0;
prntstr(str,k,l);
// cout << k << " " << l;
}
}

int main()
{
char* str = "heehasdiooi";
for(int i = 1; i< 11; i++)
{
isPalen(str,i);
// cout << str[i] << "\n";
}
getch();
}

No comments:

Post a Comment