Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.c
- // חזרה על רקורסיות
- //
- // Created by Daniel Gelfand on 21/02/2020.
- // Copyright © 2020 Daniel Gelfand. All rights reserved.
- //
- #include <stdio.h>
- void swap(char *v,char *u);
- void samenubmerz(int* Arr,int n,int* Brr, int m);
- int main()
- {
- int Arr[12] = {2,2,3,3,3,4,4,5,5,5,6,6};
- int Brr[9] = {7,5,2,5,8,4,1,2,9};
- samenubmerz(Arr, 12, Brr, 9);
- }
- void samenubmerz(int* Arr,int n,int* Brr, int m)
- {
- int i;
- int low,high,mid;
- low=0;
- high = n-1;
- for (i=0; i<m; i++)
- {
- low=0;
- high = n-1;
- while(low <= high)
- {
- mid = (low+high) / 2;
- if(Brr[i] == Arr[mid])
- {
- printf("%d\n",Brr[i]);
- }
- if(Arr[mid] > Brr[i])
- {
- low = mid+1;
- }
- else
- high = mid-1;
- }
- }
- }
- void swap(char *v,char *u)
- {
- char temp;
- temp=*v;
- *v=*u;
- *u=temp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement