ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1038. Проверка орфографии

Can any one check my code pls. Why I am gettting wrong answer?
Послано Alam Md Mahabub 27 сен 2001 14:23


#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);
}
Re:
Послано Ivan Georgiev 27 сен 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.
Re:
Послано Alam Md Mahabub 28 сен 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);
}
Re: Still WA
Послано Alam Md Mahabub 28 сен 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);
> }
>
Re:
Послано Ivan Georgiev 28 сен 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.
Re:
Послано Ivan Georgiev 28 сен 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.
Re: Can you give any judge data for which this code gives WA.
Послано Alam Md Mahabub 28 сен 2001 20:43
> > 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.
Re: Can you give any judge data for which this code gives WA.
Послано Ivan Georgiev 29 сен 2001 02:01
> > > 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
Re: What about any symbols?
Послано Book WORMs 17 апр 2002 17:54
I think that you cann't use symbols:'@','#','$','%','&'...
Re: What about any symbols?
Послано TNTeam 18 мар 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.
Re: Can you give any judge data for which this code gives WA.
Послано John Jones 24 мар 2006 12:39
Thank you very much.I think I can accept it now.
Re: Can you give any judge data for which this code gives WA.
Послано Rafal 6 июн 2007 13:07
> 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
Re: Can you give any judge data for which this code gives WA.
Послано SHMAK 5 ноя 2007 05:17
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