小编Shr*_*dhi的帖子

如何在不使用递归的情况下找到字符串的所有排列?

有人可以帮我解决这个问题:这是一个查找任意长度字符串的所有排列的程序。需要相同的非递归形式。(最好有C语言实现)

using namespace std;

string swtch(string topermute, int x, int y)
{
  string newstring = topermute;
  newstring[x] = newstring[y];
  newstring[y] = topermute[x]; //avoids temp variable
  return newstring;
}

void permute(string topermute, int place)
{
  if(place == topermute.length() - 1)
  {
    cout<<topermute<<endl;
  }
  for(int nextchar = place; nextchar < topermute.length(); nextchar++)
  {
    permute(swtch(topermute, place, nextchar),place+1);
  }
}

int main(int argc, char* argv[])
{    
  if(argc!=2)    
  {
    cout<<"Proper input is 'permute string'";
    return 1;
  }
  permute(argv[1], 0);
  return 0;    
}
Run Code Online (Sandbox Code Playgroud)

c++ iteration algorithm recursion

5
推荐指数
1
解决办法
2万
查看次数

Cscope问题 - 搜索结果不可见

我面临着一个奇怪的问题.在浏览项目的C代码时,"查找此文本字符串:"输出会产生正匹配,但文本不可见[只有搜索结果不可见而不是菜单].光标在结果列表中上下移动.有些线条有时可见,您可以在下面的屏幕截图中看到.我确实尝试更改背景颜色[从黑色到白色],删除项目文件夹中的任何cscope.out实例,重建数据库.

该系统是FC4.使用的cscope版本是15.7a.

这是一个已知的错误?有解决方案吗

屏幕截图:使用Putty拍摄屏幕截图.在gnome-terminal,konsole上可以看到相同的行为.

http://img2.pict.com/05/11/00/2823072/0/cscope01.jpg

http://img2.pict.com/53/0e/38/2823075/0/cscope02.jpg

PS:也发布在ubuntu论坛 - http://ubuntuforums.org/showthread.php?t=1402448

c cscope

4
推荐指数
1
解决办法
2470
查看次数

标签 统计

algorithm ×1

c ×1

c++ ×1

cscope ×1

iteration ×1

recursion ×1