1.C++: 判断一字符串是不是对称的, 如:abccba.BCB 编译原理. #include <vcl.h> #pragma hdrstop #include <iostream.h> #pragma argsused int main(int argc, char* argv[]) { bool flag = false; AnsiString str="qwertyuioppoiuytrewq"; int s = str.Length(); //flag = stringSymmetry(AnsiString str); bool result = false; int s_len = str.Length(); int count = s_len/2; for(int i =1 ;i<=count;i++) { char c1 =str[i]; char c2 =str[s_len-i+1]; if(c1==c2) { result = true; } else { result = false; } } if(result == true) { cout<<"this is symmetry"<<endl; } else { cout<<"this not is symmetry"<<endl; } getchar(); return 0; }