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

Why I have WA3?
Posted by Denis 28 Sep 2007 19:05
#include <fstream>
#include <stdio.h>
using namespace std;

bool is_letter (char c)
{
    return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
}

bool is_b (char c)
{
    return (c >= 'A' && c <= 'Z');
}

bool is_s (char c)
{
    return (c >= 'a' && c <= 'z');
}

int main ()
{
    //freopen ("a.in", "r", stdin);
    //freopen ("a.out", "w", stdout);
    char c;
    bool f = true;
    bool g = true;
    int ans = 0;
    char s[10010];
    int i;
    while (gets(s) != 0)
    {
        for (i = 0; i < strlen(s); ++i)
        {
            c = s[i];
            //scanf ("%c", &c);
            if (c == '.' || c == '!' || c == '?')
            {
                f = true;
                g = true;
            }
            else
            {
                if (is_letter(c))
                {
                    if (is_b(c))
                    {
                        if (!g)
                        {
                            ++ans;
                        }
                    }
                    else if (is_s(c))
                    {
                        if (f)
                        {
                            ++ans;
                        }
                    }
                    f = false;
                    g = false;
                }
                else
                {
                    g = true;
                }
            }
        }
    }
    printf ("%d\n", ans);
    return 0;
}

Edited by author 28.09.2007 19:31
Re: Why I have WA3?
Posted by SHMAK 5 Nov 2007 05:36
i think that in test where are not only ( ,.:;!?)+('A'..'Z')+('a'..'z')+(0..9) symbols...

Edited by author 05.11.2007 05:36
Re: Why I have WA3?
Posted by alp 12 Jan 2008 01:51
3th test has digits in word. If word contains digit - it's word, but in text write "A word is a sequence of letters(!!!) not containing any other symbols or ends of line". The digits is ignored and the is checked the first letter  after digits.
Re: Why I have WA3?
Posted by BlindButcher 1 Nov 2008 03:13
Try this test:
A
A
answer = 0
Re: Why I have WA3?
Posted by Varun Sharma 7 May 2009 16:31
Hi,

How come the answer is 0 ? This means, there is only one word in the entire text and that is AA. There is one mistake because second A is capital.

Varun