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 1038. Spell Checker

I don't know Why my program WA on it !! Can't anyone give Inputs.
Posted by Standlove 14 Jan 2003 12:58
If the inputs is too big to be posted.
You may test my program if you like.
I just hate WA on such easy problem very much....very much.


#include <iostream>
#include <strstream>
#include <string>
using namespace std;

const int MAX_LEN = 10000;
char lines[MAX_LEN+2];

void Solve()
{
    istrstream istr(lines);
    string marks;

    int wrongs = 0;
    while ( getline(istr, marks, '*') )
    {
        string word;
        istrstream istr2(marks.c_str());
        istr2 >> word;
        if (word.size() == 0) continue;

        if (word[0] < 'A' || word[0] > 'Z') {
            ++wrongs;
        }
        while (istr2 >> word) {
            for (int i = 1; i < word.size(); ++i) {
                if (word[i] >= 'A' && word[i] <= 'Z') {
                    ++wrongs;
                }
            }
        }
    }
    cout << wrongs << endl;
}

int main()
{
    char ch;
    int idx = 0;
    while ( cin.get(ch) )
    {
        if (ch == '.' || ch == '?' || ch == '!') {
            lines[idx] = '*';
        }
        else
        if (ch == ',' || ch == ';' || ch == ':'
               || ch == '-' || ch == '\n')
        {
            lines[idx] = ' ';
        }
        else {
            lines[idx] = ch;
        }
        ++idx;
    }
    lines[idx] = '*';
    lines[idx+1] = '\0';
    //
    Solve();
    //
    return 0;
}