题目是编写程序提示输入2个字符串,看其中一个是否为另一个字母颠倒顺序得到的。
#include<iostream>
#include<string>
using std::cout;
using std::cin;
using std::endl;
using std::string;
main()
{
string text1;
string text2;
int count=1;
cout<<"输入字符串1以#结束"<<endl;
std::getline(cin,text1,'#');
cout<<"输入字符串2以#结束"<<endl;
std::getline(cin,text2,'#');
if(sizeof text1/sizeof text1[0]==sizeof text2/sizeof text2[0])
{
for(int j=0;j<sizeof text1/sizeof text1[0];j++)
{
if(text1[j]=text2[sizeof text1/sizeof text1[0]])
{
count++;
}
}
}
else
cout<<"no"<<endl;
if(count==sizeof text1/sizeof text1[0])
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
return 0;
}