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

Help! Why do i get Runtime error on test 1?
Posted by sialLeo 14 Apr 2014 22:02
Here is my code, what's the problem?

#include <algorithm>
#include <iostream>
#include <vector>
#include <sstream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <iomanip>

using namespace std;

int main(){

    int count[26];
    int max = 0;
    char answer = '-';
    for (char p = 'a'; p < char('z') + 1; p++)
    {
        count[p] = 0;
    }
    char c;
    while (cin.get(c))
    {
    count[c]++;
    }

    for (char p = 'a'; p < char('z') + 1; p++)
    {
        if (count[p] > max){
            max = count[p];
            answer = p;
        }
    }

    cout << answer;

}