# Include <iostream> # include <algorithm> using namespace STD; int main () {string s; while (CIN> S) {int I, begin, end, total = S. size (), L = S. size (); for (I = 0; I <S. size (); ++ I) {begin = I-1; end = I + 1; // when the string length is odd, while (s [begin] = s [end] & begin> = 0 & End <L) {total ++; begin --; end ++;} begin = I; end = I + 1; // when the string length is an even number, while (s [begin] = s [end] & begin> = 0 & End <L) {total ++; begin --; end ++ ;}}cout <total <Endl ;}return 0 ;}
View code
# Include <iostream>
# Include <algorithm>
Using namespace STD;
Int main ()
{
String S;
While (CIN> S)
{
Int I, begin, end, total = S. Size (), L = S. Size ();
For (I = 0; I <S. Size (); ++ I)
{
Begin = I-1; end = I + 1; // when the string length is an odd number
While (s [begin] = s [end] & begin> = 0 & End <L)
{
Total ++; begin --; end ++;
}
Begin = I; end = I + 1; // when the string length is an even number
While (s [begin] = s [end] & begin> = 0 & End <L)
{
Total ++; begin --; end ++;
}
}
Cout <total <Endl;
}
Return 0;
}