小编cor*_*kes的帖子

尝试使用C++中的递归来确定字符串的长度

int count(string s){
    if(s == "")
      return 0;
    if(s.length == 1)
      return 1;
    return 1 + count() //This is what I can't figure out. How to traverse the string.
    //I just need a hint, not a full on answer.
}
Run Code Online (Sandbox Code Playgroud)

我不知道如何遍历一个字符串.

c++ string recursion counting

6
推荐指数
1
解决办法
5716
查看次数

标签 统计

c++ ×1

counting ×1

recursion ×1

string ×1