usepermuter.cpp
来自「C++&datastructure书籍源码,以前外教提供现在与大家共享」· C++ 代码 · 共 34 行
CPP
34 行
#include <iostream>
#include <string>
using namespace std;
#include "tvector.h"
#include "permuter.h"
int main()
{
tvector<int> list;
tvector<string> slist;
string names[] = {"first", "second", "third"};
int k;
for(k=0; k < 3; k++)
{ list.push_back(k);
slist.push_back(names[k]);
}
Permuter p(list);
for(p.Init(); p.HasMore(); p.Next())
{ p.Current(list);
for(k=0; k < list.size(); k++)
{ cout << list[k] << " ";
}
cout << endl;
}
for(p.Init(); p.HasMore(); p.Next())
{ p.Current(list);
for(k=0; k < list.size(); k++)
{ cout << slist[list[k]] << " ";
}
cout << endl;
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?