#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
int i, j;
while(cin >> s)
{
getchar();
set<string>st;
int p = s.size() - 1;
for(i=0;i<=p;i++)
{
string str = "";
str = str + s[i];
st.insert(str);
}
for(i=0;i<p;i++)
{
string str = "";
str = str + s[i];
for(j=i+1;j<=p;j++)
{
str = str + s[j];
string pk = str;
reverse(pk.begin(), pk.end());
if(pk == str)
{
st.insert(pk);
}
}
}
cout << "The string " << "'" << s << "' contains " << st.size() <<" palindromes." << "\n";
}
return 0;
}
using namespace std;
int main()
{
string s;
int i, j;
while(cin >> s)
{
getchar();
set<string>st;
int p = s.size() - 1;
for(i=0;i<=p;i++)
{
string str = "";
str = str + s[i];
st.insert(str);
}
for(i=0;i<p;i++)
{
string str = "";
str = str + s[i];
for(j=i+1;j<=p;j++)
{
str = str + s[j];
string pk = str;
reverse(pk.begin(), pk.end());
if(pk == str)
{
st.insert(pk);
}
}
}
cout << "The string " << "'" << s << "' contains " << st.size() <<" palindromes." << "\n";
}
return 0;
}
Comments
Post a Comment