首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

Dev C++如何编译运行结果出人意料

2012-02-20 
Dev C++怎么编译运行结果出人意料我写了一段判断字符是否为前后都以相同字母组成,是返回True,否则返回fals

Dev C++怎么编译运行结果出人意料
我写了一段判断字符是否为前后都以相同字母组成,是返回True,否则返回false。我在VC6.0下程序运行结果正确,但我在Dev   C++编译运行,结果出人意料。请问这是为什么?程序如下:

#include   <iostream>
#include   <string>
using   std::cout;
using   std::endl;
using   std::string;

bool   isPal(const   string&   str,   int   startIndex,   int   endIndex){
          if(startIndex> =endIndex-1)
                  return   true;
          else   if(str[startIndex]!=str[endIndex-1])
                  return   false;
          else
                  isPal(str,   startIndex+1,   endIndex-1);
         
}

int   main(){
        cout < <isPal( "dad ",0,3) < <endl;
        cout < <isPal( "level ",0,5) < <endl;
        cout < <isPal( "ouyang ",0,6) < <endl;
        cout < <isPal( "madamimadam ",0,11) < <endl;
}

[解决办法]
出啥结果?
[解决办法]
else
isPal(str, startIndex+1, endIndex-1);
漏写return了。
[解决办法]
我这里是
208
67
0
67
请按任意键继续. . .

用的dev

热点排行