Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <string.h>
- #define MOD (int)1e9 + 7
- #define PRIME 31
- #define NMAX 10
- #define NAME_MAX_LEN 30
- char s[NMAX][NAME_MAX_LEN], dist[NMAX][NAME_MAX_LEN];
- int freq[NMAX];
- int main() {
- int n;
- scanf("%d", &n);
- for (int i = 0; i < n; i++) {
- scanf("%s", s[i]);
- }
- int distSz = 0;
- for (int i = 0; i < n; i++) {
- int pos = -1;
- for (int j = 0; j < distSz && pos == -1; j++) {
- if (!strcmp(dist[j], s[i])) {
- pos = j;
- }
- }
- if (pos == -1) {
- freq[distSz] = 1;
- strcpy(dist[distSz++], s[i]);
- } else {
- freq[pos]++;
- }
- }
- for (int j = 0; j < distSz; j++) {
- printf("%s: %d\n", dist[j], freq[j]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement