ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1585. Penguins

Теряюсь в догадках, Что не так?
Posted by VladGrin 3 Feb 2018 05:39
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>

int main()
{
int N;
int i;
int emp = 0, mac = 0, lit = 0;

scanf("%i",&N);
char **str = (char**)malloc(N * sizeof(char));
for(i = 0; i < N; i++)
str[i] = (char*)malloc(20);

fflush(stdin);
for(i = 0; i < N; i++)
gets(str[i]);

for(i = 0; i < N; i++)
{
if(strcmp(str[i], "Emperor Penguin") == 0)
emp++;
if(strcmp(str[i], "Macaroni Penguin") == 0)
mac++;
if(strcmp(str[i], "Little Penguin") == 0)
lit++;
}
if(emp > mac && emp > lit)
printf("%s\n", "Emperor Penguin");
if(mac > emp && mac > lit)
printf("%s\n", "Macaroni Penguin");
if(lit > mac && lit > emp)
printf("%s\n", "Little Penguin");

for(i = 0; i < N; i++)
free(str[i]);
free (str);
return 0;
}
Re: Теряюсь в догадках, Что не так?
Posted by mNT 20 Jun 2018 16:05