Zju 2744 echo character HDU 1544

Source: Internet
Author: User

 

 

 

 

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.