fork(1) download
  1. #include <vector>
  2. #include <string>
  3. #include <algorithm>
  4. #include <random>
  5. #include <iostream>
  6. int main(){
  7. std::vector<std::string> tabNom(0);
  8. tabNom.push_back("Pierre");
  9. tabNom.push_back("Nicolas");
  10. tabNom.push_back("Lucas");
  11. tabNom.push_back("Léa");
  12. tabNom.push_back("Jean");
  13. tabNom.push_back("Marie");
  14. tabNom.push_back("Claude");
  15. tabNom.push_back("Paul");
  16. tabNom.push_back("Mathieu");
  17. tabNom.push_back("Julien");
  18. tabNom.push_back("Lucie");
  19. tabNom.push_back("Chloé");
  20. tabNom.push_back("Kevin");
  21. tabNom.push_back("Sophie");
  22.  
  23. std::random_device rd;
  24. std::mt19937 g(rd());
  25. std::shuffle(tabNom.begin(), tabNom.end(), g);
  26. for(size_t i = 0 ; i <tabNom.size(); ++i){
  27. auto j = (i+1)%(tabNom.size());
  28. std::cout<<tabNom[i]<<" offrira son cadeau a "<<tabNom[j]<<"\n";
  29. }
  30. return 0;
  31. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
In file included from prog.cpp:4:
In file included from /usr/bin/../lib/gcc/i586-linux-gnu/4.9/../../../../include/c++/4.9/random:35:
/usr/bin/../lib/gcc/i586-linux-gnu/4.9/../../../../include/c++/4.9/bits/c++0x_warning.h:32:2: error: This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
 ^
prog.cpp:23:10: error: no type named 'random_device' in namespace 'std'
    std::random_device rd;
    ~~~~~^
prog.cpp:24:17: error: expected ';' after expression
    std::mt19937 g(rd());
                ^
                ;
prog.cpp:24:10: error: no member named 'mt19937' in namespace 'std'
    std::mt19937 g(rd());
    ~~~~~^
prog.cpp:25:10: error: no member named 'shuffle' in namespace 'std'
    std::shuffle(tabNom.begin(), tabNom.end(), g);
    ~~~~~^
prog.cpp:25:48: error: use of undeclared identifier 'g'
    std::shuffle(tabNom.begin(), tabNom.end(), g);
                                               ^
prog.cpp:27:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
        auto j = (i+1)%(tabNom.size());
        ^
1 warning and 6 errors generated.
stdout
Standard output is empty