210699 判断字符串是否是回文数

题目描述

输入一个字符串,判断该字符串是否为回文字符串。回文字符串是指顺读和倒读都一样的字符串

输入格式

一行字符串(字符串中没有空格,字符串长度不超过100)

输出格式

如果字符串是回文,输出yes,否则输出no。

样例

样例输入

zxcvcxz
样例输出

yes
数据范围与提示 分类标签

[字符数组]

C++题解代码

#include <bits/stdc++.h>
using namespace std;

string a;
int b;


// The main procedure
int main() {
  cin>>a;
  b = (a.size()-1);
  for (int i = 0; i < (a.size()/2); i++) {
    if (a[i] != a[b]) {
      cout<<"no";
      return 0;
    }
    b--;
  }
  cout<<"yes";
  return 0;
}

Blockly题解代码图片