daily pastebin goal
3%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int intersezione(int* a, int dima, int* b, int dimb){
  4.     int i=0;
  5.     int j=0;
  6.     int conta=0;
  7.     int trovato=0;
  8.    
  9.     while(i<dima && j<dimb && !trovato){
  10.         if(a[i]==b[j]){
  11.             trovato=1;
  12.             conta+=1;
  13.             i++;
  14.             j++;
  15.         }
  16.        
  17.     }
  18.  return conta;
  19. }
  20. int main(){
  21.     int dima;
  22.     int i;
  23.     scanf("%d", &dima);
  24.     int *p;
  25.     p=(int*)malloc(dima*sizeof(int*));
  26.     for(i=0; i<dima; i++)
  27.     scanf("%d",p+i);
  28.    
  29.     int dimb;
  30.     int j;
  31.     scanf("%d", &dimb);
  32.     int *q;
  33.     q=(int*)malloc(dimb*sizeof(int*));
  34.     for(j=0; j<dimb; j++)
  35.     scanf("%d", q+j);
  36.    
  37.     printf("%d", intersezione(p,dima,q,dimb));
  38.    
  39.     return 0;
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top