系統呼叫了 abort 函式! *** stack smashing detected ***: terminated Aborted (core dumped)
#include
#include
using namespace std;
int main() {
int i , j ;
string a , b ;
while( cin >> a ) {
bool flag = 1 ;
j = a.size() ;
for( i = 0 ; i < j ; i++ ) {
if( a[i] >= 'a' && a[i] <= 'z' ) {
a[i] -=32 ;
}
b[j-i-1] = a[i] ;
if( !isalpha( b[j-i-1] ) ) {
b[j-i-1] = '%' ;
}
}
for( i = 0 ; i < j / 2 ; i++ ) {
if( a[i] != b[i] ) {
if( b[i] != '%' ) {
flag = 0 ;
}
}
}
if( flag == 1 ) cout << "yes !" << endl;
else cout << "no..." << endl;
}
return 0;
}
查看評分詳細結果。
系統呼叫了 abort 函式! *** stack smashing detected ***: terminated Aborted (core dumped)
一開始b是空字串,你不能讓b[j-i-1]改變