记住……
· 1nm
基本类型的小于运算符是不能重载的
用错了后果可是很严重的哦……
还是用functor吧。
{% highlight cpp %} //PKU 1256 AC //80K 140MS
#include #include #include
using namespace std;
string STR;
class Less_CHAR { public: bool operator() (const char &a,const char &b) const { if ( toupper(a) == toupper(b) ) return a < b; else return (toupper(a) < toupper(b)); } };
void Input() { cin >> STR; }
void Permutate() { sort(STR.begin(),STR.end(),Less_CHAR()); do { cout << STR << endl; } while (next_permutation(STR.begin(),STR.end(),Less_CHAR())); }
int main()
{ int i,iCase; cin >> iCase; for (i=0;i<iCase;++i) { Input(); Permutate(); } return 0; } {% endhighlight %}
分类: 生活