fork(2) download
  1. #include <iostream>
  2. #include <set>
  3.  
  4. using std::set;
  5. using std::cout;
  6. using std::endl;
  7.  
  8. int main() {
  9.  
  10. int A[6] = { 3, 5, 7, 3, 3, 5 };
  11.  
  12. int countPS = 0;
  13.  
  14. for ( int i = 1; i <= 6; i++ ) {
  15.  
  16. set<int> P;
  17. P.insert( A , A + i );
  18.  
  19. for ( int j = 5; j >= 0; j-- ) {
  20.  
  21. set<int> S;
  22. S.insert( A + j, A + 6 );
  23.  
  24. if ( P == S )
  25. countPS++;
  26. }
  27. }
  28. cout << "The number of elements in list (P,S) = " << countPS << endl;
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
The number of elements in list (P,S) = 14