fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a[] = {6, 7, 3, 2};
  6. int b[] = {2, 3};
  7. int n = 4;
  8. int m = 2;
  9. bool subset = true;
  10.  
  11. for(int i = 0; i < m; i++) {
  12. bool found = false;
  13. for(int j = 0; j < n; j++) {
  14. if(b[i] == a[j]) {
  15. found = true;
  16. break;
  17. }
  18. }
  19. if(!found) {
  20. subset = false;
  21. break;
  22. }
  23. }
  24.  
  25. if(subset) cout << "b is a subset of a" << endl;
  26. else cout << "b is not a subset of a" << endl;
  27.  
  28. return 0;
  29. }
  30.  
  31.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
b is a subset of a