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



#include<stdio.h>

void main(void)
{

    int ch,c,start_s,start_w;

    c=0;
    start_s=1,start_w=0;
    while((ch=getchar())!=-1)
    {
        if(ch=='\n')continue;
        if(ch=='.' || ch=='?' || ch=='!')
        {start_s=1;continue;}
        if(ch==' '){start_w=1;continue;}
        if(start_s && ch>='a'  && ch<='z')
        {start_s=start_w=0;c++;continue;}
        else
        {
    if(!start_s && start_w && ch>='A' && ch<='Z')
                c++;
            start_w=0;
            start_s=0;
        }
    }
    printf("%d\n",c);
}
Ivan Georgiev Re: [11] // Problem 1038. Spell Checker 27 Sep 2001 14:45
Well, when you encounter a line break you should change
start_w to 0 as a line break is a word separator.

Good luck.
Alam Md Mahabub Re: [10] // Problem 1038. Spell Checker 28 Sep 2001 02:42
Thanks to Ivan Georgiev
But still I am getting WA.
Would you check it again.

Here the modified code

#include<stdio.h>

void main(void)
{
    int ch,c,start_s,start_w;
    freopen("D:\\1038.in","rt",stdin);

    c=0;
    start_s=1,start_w=0;
    while((ch=getchar())!=-1)
    {
        if(ch=='\n'){start_s=1,start_w=0;continue;}
        if(ch=='.' || ch=='?' || ch=='!')
        {start_s=1;continue;}
        if(ch==' ')
        {start_w=1;continue;}
        if(start_s && ch>='a'  && ch<='z')
        {start_s=start_w=0;c++;continue;}
        else
        {
    if(!start_s && start_w && ch>='A' && ch<='Z')
            c++;
            start_w=0;start_s=0;
        }
    }
    printf("%d\n",c);
}
Alam Md Mahabub Re: Still WA // Problem 1038. Spell Checker 28 Sep 2001 02:43
> Thanks to Ivan Georgiev
> But still I am getting WA.
> Would you check it again.
>
> Here the modified code
>
> #include<stdio.h>
>
> void main(void)
> {
>     int ch,c,start_s,start_w;
>     freopen("D:\\1038.in","rt",stdin);
>
>     c=0;
>     start_s=1,start_w=0;
>     while((ch=getchar())!=-1)
>     {
>         if(ch=='\n'){start_s=1,start_w=0;continue;}
>         if(ch=='.' || ch=='?' || ch=='!')
>         {start_s=1;continue;}
>         if(ch==' ')
>         {start_w=1;continue;}
>         if(start_s && ch>='a'  && ch<='z')
>         {start_s=start_w=0;c++;continue;}
>         else
>         {
>     if(!start_s && start_w && ch>='A' && ch<='Z')
>             c++;
>             start_w=0;start_s=0;
>         }
>     }
>     printf("%d\n",c);
> }
>
Ivan Georgiev Re: // Problem 1038. Spell Checker 28 Sep 2001 04:21
> Thanks to Ivan Georgiev
> But still I am getting WA.
> Would you check it again.
>
> Here the modified code
>
> #include<stdio.h>
>
> void main(void)
> {
>     int ch,c,start_s,start_w;
>     freopen("D:\\1038.in","rt",stdin);
>
>     c=0;
>     start_s=1,start_w=0;
>     while((ch=getchar())!=-1)
>     {
>         if(ch=='\n'){start_s=1,start_w=0;continue;}
>         if(ch=='.' || ch=='?' || ch=='!')
>         {start_s=1;continue;}
>         if(ch==' ')
>         {start_w=1;continue;}
>         if(start_s && ch>='a'  && ch<='z')
>         {start_s=start_w=0;c++;continue;}
>         else
>         {
>     if(!start_s && start_w && ch>='A' && ch<='Z')
>             c++;
>             start_w=0;start_s=0;
>         }
>     }
>     printf("%d\n",c);
> }
>

Words can be separated by more than one space (and other
characters as well). I think that's the problem.
Ivan Georgiev Re: [7] // Problem 1038. Spell Checker 28 Sep 2001 04:22
> Thanks to Ivan Georgiev
> But still I am getting WA.
> Would you check it again.
>
> Here the modified code
>
> #include<stdio.h>
>
> void main(void)
> {
>     int ch,c,start_s,start_w;
>     freopen("D:\\1038.in","rt",stdin);
>
>     c=0;
>     start_s=1,start_w=0;
>     while((ch=getchar())!=-1)
>     {
>         if(ch=='\n'){start_s=1,start_w=0;continue;}
>         if(ch=='.' || ch=='?' || ch=='!')
>         {start_s=1;continue;}
>         if(ch==' ')
>         {start_w=1;continue;}
>         if(start_s && ch>='a'  && ch<='z')
>         {start_s=start_w=0;c++;continue;}
>         else
>         {
>     if(!start_s && start_w && ch>='A' && ch<='Z')
>             c++;
>             start_w=0;start_s=0;
>         }
>     }
>     printf("%d\n",c);
> }
>

Words can be separated by more than one space (and other
characters as well). I think that's the problem.
> > Thanks to Ivan Georgiev

Can you give any judge data for that it gives WA.
I think that will be good for me to judge.
> > > Thanks to Ivan Georgiev
>
> Can you give any judge data for that it gives WA.
> I think that will be good for me to judge.

Try this tests:

The old vaRsag my
Antonesgh..%sg4mahng 35tsavx
3mnkxb o o oo AA gfsd . sdgw a
aA
Aa

The answer is 5

I am good and evil.
i $JHBFS# dreams dreA
MS and DREAMS.222

The answer is 12
Book WORMs Re: What about any symbols? [1] // Problem 1038. Spell Checker 17 Apr 2002 17:54
I think that you cann't use symbols:'@','#','$','%','&'...
TNTeam Re: What about any symbols? // Problem 1038. Spell Checker 18 Mar 2006 00:56
Input contains a text that consists of capital and small letters of the Latin alphabet (A–Z, a–z), punctuation marks (.,;:-!?) and spaces.
Thank you very much.I think I can accept it now.
> Try this tests:
>
> The old vaRsag my
> Antonesgh..%sg4mahng 35tsavx
> 3mnkxb o o oo AA gfsd . sdgw a
> aA
> Aa

My AC code returns 4.

Edited by author 06.06.2007 13:07
strange... but there are 5 mistakes:

The old va[R]sag my
Antonesgh..%[s]g4mahng 35tsavx
3mnkxb o o oo A[A] gfsd . [s]dgw a
a[A]
Aa