Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int function(int bigarr[], int smallarr[], int size1, int size2);
- int main() {
- 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};
- int smallarr[] = { 1,2,3 };
- int size1 = 23, size2 = 3;
- cout << function(bigarr, smallarr, size1, size2);
- return 0;
- }
- int function(int bigarr[], int smallarr[], int size1, int size2) {
- int i=0;
- int pos2;
- while (i < size1) {
- int c = 0;
- for (pos2 = 0; pos2 < size2; pos2++) if (bigarr[pos2 + i] == smallarr[pos2])c++;
- if (c == 3) return ++i;
- i++;
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement