diff --git a/Intersection of two Integer arrays/arrayIntersection.c b/Intersection of two Integer arrays/arrayIntersection.c new file mode 100644 index 0000000..f9e78e5 --- /dev/null +++ b/Intersection of two Integer arrays/arrayIntersection.c @@ -0,0 +1,33 @@ +#include + +int main() +{ + int sa, sb; + printf("Inform the size of the first list: "); + scanf("%d", &sa); + int ma[sa]; + printf("Inform the size of the second list: "); + scanf("%d", &sb); + int mb[sb]; + printf("Inform the list of integers space separated:\n"); + for (int i = 0; i < sa; i++) { + scanf("%d", &ma[i]); + } + printf("Inform the list of integers space separated:\n"); + for (int i = 0; i < sb; i++) { + scanf("%d", &mb[i]); + } + + printf("Intersection between first and second list:\n"); + for (int i = 0; i < sa; i++) { + for (int j = 0; j < sb; j++) { + if (ma[i] == mb[j]) { + printf("%d ", ma[i]); + break; + } + } + } + printf("\n"); + + return 0; +}