ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1723. Sandro's Book

Why i got wrong answer
Posted by iCE Hin 25 Aug 2011 18:18
#include <cstdio>
#include <cstring>

int n[25], k[2];
char ch[50];

int main(){
    scanf("%s",ch);
    int x = strlen(ch);
    for ( int i = 0; i < x; i++ )
        n[ch[i]-'a']++;
    for ( int i = 0; i < 24; i++ )
        if ( n[i] > k[0] ){
            k[0] = n[i];
            k[1] = i;
        }
    printf("%c", k[1]+'a');
    scanf("\n");
    return 0;
}
No subject
Posted by YarContester 25 Aug 2011 18:21


Edited by author 25.08.2011 18:32
Re: Why i got wrong answer
Posted by daftcoder [Yaroslavl SU] 25 Aug 2011 18:32
There are 26 letters in English alphabet =)
Also beware about /0 char in the end of line, use char ch[51], MAXLEN+1.
Re: Why i got wrong answer
Posted by iCE Hin 27 Aug 2011 08:53
i change it and still wrong