fork(2) download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. int main()
  5. {
  6. srand(time(NULL));
  7. std::vector<int> srcVec;
  8.  
  9. srcVec.push_back([]
  10. {
  11. int temp = rand()%30;
  12. if (temp % 2 == 0)
  13. return temp;
  14. else return 0;
  15. }());
  16. std::cout<<srcVec[0]<<std::endl;
  17. return EXIT_SUCCESS;
  18. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
8