Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int A[] = {1,2,3,4,5};
- int B[] = {1,3,4};
- int ReadArr(int Arr[], int s){
- int i;
- for(i = 0; i < s; i++){
- scanf("%d", &Arr[i]);
- }
- }
- int Intersect(int sA, int sB){
- int I = 0;
- int ia, ib;
- for(ia = 0; ia < sA; ia++){
- for(ib = 0; ib < sB; ib++){
- if(A[ia] == B[ib]){
- I += 1;
- break;
- }
- }
- }
- return I;
- }
- int Union(int sA, int sB){
- int U = sA + sB;
- int ia, ib;
- for(ia = 0; ia < sA; ia++){
- for(ib = 0; ib < sB; ib++){
- if(A[ia] == B[ib]){
- U -= 1;
- break;
- }
- }
- }
- return U;
- }
- int main(){
- int sA, sB;
- int I, U;
- scanf("%d", &sA);
- ReadArr(A, sA);
- scanf("%d", &sB);
- ReadArr(B, sB);
- I = Intersect(sA, sB);
- U = Union(sA, sB);
- printf("%d\n", I);
- printf("%d\n", U);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement