File tree Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Original file line number Diff line number Diff line change 1+ //
2+ // main.cpp
3+ // CODE-CHEF
4+ //
5+ // Created by Prince Kumar on 18/05/19.
6+ // Copyright © 2019 Prince Kumar. All rights reserved.
7+ //
8+ // ------- ** Attendance ** --------- //
9+
10+ #include < iostream>
11+ using namespace std ;
12+ int main ()
13+ {
14+ int T;cin>>T;
15+ while (T--)
16+ {
17+ int n; cin>>n;
18+ string f[n];
19+ string l[n];
20+
21+ for (int i=0 ;i<n;i++)
22+ {
23+ cin>>f[i]>>l[i]; // first name and last name
24+ }
25+
26+ int a[n];
27+ for (int i=0 ;i<n;i++){a[i]=0 ;}
28+
29+ // initalise the array - a --> to 0
30+
31+ for (int i=0 ;i<n-1 ;i++)
32+ {
33+ for (int j=i+1 ;j<n;j++)
34+ {
35+ if (f[i]==f[j])
36+ {a[i]++; a[j]++;}
37+ }
38+ }
39+
40+ // we check the condition on array a
41+
42+ for (int i=0 ;i<n;i++)
43+ {
44+ if (a[i]==0 )
45+ {
46+ cout<<f[i]<<endl;
47+ }
48+ else
49+ {
50+ cout<<f[i]<<" " <<l[i]<<endl;
51+ }
52+ }
53+ }
54+ }
55+
56+
57+
58+
59+
60+
You can’t perform that action at this time.
0 commit comments