-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_array1.c
More file actions
76 lines (51 loc) · 1.39 KB
/
list_array1.c
File metadata and controls
76 lines (51 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// There are N students in a class. Students having two arrears are given the chance to appear for re-exam to clear those subjects in the same semester. Students can select subject1 or subject2 or both. Find the number of students who registered for both subjects.
// Input:
// 1. The first line of the input contains a single integer N denoting the number of students.
// 2. The second line contains N space-separated positive integers represents array subject1.
// 3. The second line contains N space-separated positive integers represents array subject2.
// Output: Print the count of students who registered for both subjects.
// Constraints:
// 1. 1 <= N <= 100000
// 2. 1 <= subject1[i] <= 100000
// 3. 1 <= subject2[i] <= 100000
// Sample Input 1
// Input:
// 5
// 1 2 3 4 5
// 3 4 5 6 7
// Output:
// 3
// Sample Input 2
// Input:
// 10
// 21 41 56 78 97 63 51 22 54 87
// 12 10 9 45 32 65 98 51 41 78
// Output:
// 2
#include <stdio.h>
int main()
{
long int n;
int c = 0;
scanf("%ld", &n);
long int arr1[n], arr2[n];
for (int i = 0; i < n; i++)
{
scanf("%ld", &arr1[i]);
}
for (int i = 0; i < n; i++)
{
scanf("%ld", &arr2[i]);
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
if (arr1[i] == arr2[j])
{
c++;
}
}
}
printf("%d", c);
}