Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int function(int bigarr[], int smallarr[], int size1, int size2);
  5. int main() {
  6. int bigarr[] = { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3};
  7. int smallarr[] = { 1,2,3 };
  8. int size1 = 23, size2 = 3;
  9. cout << function(bigarr, smallarr, size1, size2);
  10. return 0;
  11.  
  12.  
  13. }
  14. int function(int bigarr[], int smallarr[], int size1, int size2) {
  15. int i=0;
  16. int pos2;
  17. while (i < size1) {
  18. int c = 0;
  19. for (pos2 = 0; pos2 < size2; pos2++) if (bigarr[pos2 + i] == smallarr[pos2])c++;
  20. if (c == 3) return ++i;
  21. i++;
  22.  
  23. }
  24. return -1;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement