Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- char word[50], maxword[50], wword[50];
- int n, i, j, maxcount, count, equals;
- char **words;
- scanf("%d", &n);
- words = malloc(n*sizeof(char*));
- for ( i = 0; i < n; i++ )
- {
- words[i] = malloc(50*sizeof(char));
- }
- for (i = 0; i < n; i++) {
- scanf("%s", word);
- for (j = 0; j < 50; j++) {
- words[i][j] = word[j];
- }
- }
- maxcount = 0;
- for (i = 0; i < n; i++) {
- for (j = 0; j < 50; j++) {
- word[j] = words[i][j];
- }
- count = 0;
- for (i = 0; i < n; i++) {
- equals = 1;
- for (j = 0; j < 50; j++) {
- if (word[j] != words[i][j]) {
- equals = 0;
- }
- }
- if (equals == 1) {
- count++;
- }
- }
- if (count > maxcount) {
- maxcount = count;
- for (j = 0; j < 50; j++) {
- maxword[j] = word[j];
- }
- }
- }
- printf("%s %d\n", maxword, count);
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement