Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Intersection of two Integer arrays/arrayIntersection.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <stdio.h>

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;
}