-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgames.cpp
More file actions
40 lines (39 loc) · 816 Bytes
/
games.cpp
File metadata and controls
40 lines (39 loc) · 816 Bytes
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
#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int homecolor[n];
int guestcolor[n];
for(int i=0;i<n;i++){
cin>>homecolor[i];
// cout<<" ";
cin>>guestcolor[i];
}
// for(int i=0;i<n;i++){
// cout<<homecolor[i]<<" ";
// }
// // cout<<endl;
// // for(int i=0;i<n;i++){
// cout<<homecolor[i]<<" "<<guestcolor[i];
// cout<<endl;
// }
int count =0;
for(int i=0;i<n-1;i++){
for(int j=i+1;j<n;j++){
if(homecolor[i]==guestcolor[j]){
count++;
}
}
}
for(int i=0;i<n-1;i++){
for(int j=i+1;j<n;j++){
if(guestcolor[i]==homecolor[j]){
count++;
}
}
}
cout<<count;
return 0;
}