#8330: OLE??


ByTutu (ByTu)


 
錯誤訊息是:請勿輸入非題目要求的文字:yes
 
我想是判斷式出了問題 可是又不知錯在哪? 
------------------- 
 
#include "stdafx.h"
#include <string>
#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
std::string a; 

    while ( ! cin.eof() ) 
{
          std::cin >> a; 
                  int len=a.length();

for(int i=0;i<=len/2;i++)
{
if(a[i]!=a[len-1-i])
{
cout<<"no\n";
break;
}
  
if  (i==(len+1)/2-1)
cout<<"yes\n";

}
}
return 0;
}

#8332: Re:OLE??


rosynirvana (rosynirvana)


 
錯誤訊息是:請勿輸入非題目要求的文字:yes
 
我想是判斷式出了問題 可是又不知錯在哪? 
------------------- 
 
#include "stdafx.h"
#include
#include

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
std::string a; 

    while ( ! cin.eof() ) 
{
          std::cin >> a; 
                  int len=a.length();

for(int i=0;i<=len/2;i++)
{
if(a[i]!=a[len-1-i])
{
cout<<"no\n";
break;
}
  
if  (i==(len+1)/2-1)
cout<<"yes\n";

}
}
return 0;
}


if  (i==(len+1)/2-1)
cout<<"yes\n";
放到for的外面去,不然每次都会输出一个yes
另外建议不要用vc++的stdafx _tmain之类的,OJ可能无法编译的