fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. char tb[]="1234567";
  8. const unsigned size=7;
  9. for(unsigned nr=0;;++nr)
  10. {
  11. unsigned NR=0;
  12. for(unsigned w=0;w<size-1;NR*=(size-(++w))) for(unsigned v=w+1;v<size;++v) if(tb[v]<tb[w]) ++NR;
  13. if(NR!=nr)
  14. {
  15. cout<<NR<<"!="<<nr<<endl;
  16. cin.get();
  17. }
  18. if(!next_permutation(tb,tb+7)) break;
  19. }
  20. cout<<"END"<<endl;
  21. return 0;
  22. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
END