-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy path10420.cpp
More file actions
executable file
·43 lines (36 loc) · 858 Bytes
/
10420.cpp
File metadata and controls
executable file
·43 lines (36 loc) · 858 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
41
42
43
/* Problem: List of Conquests UVa 10420
Programmer: Md. Mahmud Ahsan
Compiled: Visual C++ 6.0
Date: 18-10-04
*/
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
// cmp function for quick sort
int cmp(const void *a, const void *b){
return strcmp( (char*) a, (char*) b);
}
int main(){
char str[2200][100]; // list of countries
char temp[100];
int input;
int i, j;
cin >> input;
for (i = 0; i < input; i++){
cin >> str[i];
cin.getline(temp, sizeof(temp)); // to ignore woman's name
}
qsort(str, input, sizeof(str[0]), cmp); // alphabetical order
int count;
for (i = 0; i < input; i+= count){
count = 0;
cout << str[i] << " ";
for (j = i; j < input; j++){
if (strcmp(str[i], str[j]) == 0)
++count;
}
cout << count << endl;
}
return 0;
}