#14506: 請問這樣為甚麼錯? RE (SIGABRT)


atiger1 (neko)

學校 : 義守大學
編號 : 80476
來源 : [42.74.108.22]
最後登入時間 :
2019-11-13 20:41:10
a022. 迴文 | From: [1.175.26.98] | 發表日期 : 2018-07-21 15:42

#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
int main()
{
string a,b;
long int length;
bool t=0;
while(cin >> a)
{
length = a.size();
for(long int i=0;i<length;i++)
{
b[length-1-i]=a[i];
}
for(long int j=0;j<length;j++)
{
//cout << "a=" << a[j] << "\n";
//cout << "b=" << b[j] << "\n";
if(a[j]==b[j])
{
t=1;
}
else
{
t=0;
}
}
if(t==1)
{
cout << "yes" << "\n";
t=0;
}
else
{
cout << "no" << "\n";
t=0;
}
}
return 0;
}

 
#14510: Re:請問這樣為甚麼錯? RE (SIGABRT)


anandrewboy70900 (ShowTsai)

學校 : 國立中央大學
編號 : 27736
來源 : [203.204.218.144]
最後登入時間 :
2024-02-07 22:53:10
a022. 迴文 | From: [123.195.139.82] | 發表日期 : 2018-07-21 23:14

b.resize(length);

 

 
ZeroJudge Forum