fork download
  1. //(c)Terminator
  2. #include <iostream>
  3. using namespace std;
  4.  
  5.  
  6.  
  7. bool isIncludedAtoB(const int* a, unsigned n1,
  8. const int* b, unsigned n2){
  9. const int* p1, *p2;
  10. const int* e1 = a + n1;
  11. const int* e2 = b + n2;
  12.  
  13. for(; b != e2; ++b){
  14.  
  15. p1 = a;
  16. p2 = b;
  17. while((p1 != e1) && (p2 != e2)){
  18. if(*p1 != *p2)
  19. break;
  20. ++p1;
  21. ++p2;
  22. }
  23.  
  24. if(p1 == e1)
  25. return true;
  26. }
  27. return false;
  28. }
  29.  
  30.  
  31.  
  32. int main(void){
  33. int a[] = { 1, 0, 1, 1 };
  34. int b[] = { 0, 1, 0, 1, 1, 0 };
  35.  
  36. bool ret = isIncludedAtoB(a, sizeof(a)/sizeof(a[0]),
  37. b, sizeof(b)/sizeof(b[0]));
  38. (ret) ?
  39. cout << "Yes included a to b." << endl
  40. :
  41. cout << "Not !!!" << endl;
  42. return 0;
  43. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
Yes included a to b.