Problem D: 回文字符串(字符串)

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:10 Solved:6

Description

输入一串字符,其长度小于250。判断该串字符是否构成回文。所谓回文是指从左到右和从右到左读一串字符的值是一样的。如abcba就是一个回文。

Input

一行字符串。

Output

如果是回文字符串输出“Yes”,如果不是则输出“No”。

Sample Input Copy

abcba

Sample Output Copy

Yes

HINT

回文串就是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。
字符串视频讲解:https://www.bilibili.com/video/BV1CWCYYmEvj/?spm_id_from=333.788.videopod.sections&vd_source=ed609f9463861996afb742d2bd8b5a46

1.length()成员函数

length()函数是string的内置成员函数,用于返回string类型字符串的实际长度。
示例1:
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s="hello world!";
  cout<<s.length()<<endl;
  return0;
}
输出:12

2.size()成员函数

size()函数与length()一样,没有本质区别。

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s= "hello world!";
    cout << s.size() << endl;
    return 0;
}

输出结果:12

Source/Category