第二次上机作业(3)
//string 和.size
#include<iostream>
#include<string>
using namespace std;
int main() {
string carray[100],x;
int is_palindrome = 1;
cout << "请输入一组字符串" << endl;
getline(cin, x);
int len = x.size();
for (int i = 1; i <len / 2; i++) {
if (carray[i] != carray[len - 1 - i]) {
is_palindrome = 0;
break;
}
}
if (is_palindrome)
cout << "该字符串不可回文" << endl;
else
cout << "该字符串可回文" << endl;
return 0;
}
gerline(cin,x)不跳过空格,cin跳过空格
,size可计算字符串长度