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

Обсуждение задачи 1027. Снова D++

WA1
Послано Gelioscope 24 июн 2011 20:10
This is my code:
#include <stdio.h>
#define ulong unsigned long
void main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt","rt",stdin);
    freopen("out.txt","wt",stdout);
#endif
    bool comment=0,arithmetical=0;
    long brakets=0;
    char syms[10001];
    ulong i;
    while(!feof(stdin))
    {
        gets(syms);
        i=0;
        while(syms[i])
        {
            if(comment)
            {
                while(syms[i])
                {
                    if(syms[i]=='*')
                    {
                        ++i;
                        if(syms[i]==')')
                        {
                            ++i;
                            comment=0;
                            break;
                        }
                    }
                    ++i;
                }
            }
            if(arithmetical)
            {
                while(syms[i])
                {
                    if(!((syms[i]>=0x28&&syms[i]<=0x2B)||(syms[i]>=0x30&&syms[i]<=0x39)||syms[i]=='-'||syms[i]=='/'||syms[i]=='\n'||syms[i]=='='))
                    {
                        printf("NO");
                        return;
                    }
                    if(syms[i]=='(')
                    {
                        ++i;
                        if(syms[i]=='*')
                        {
                            ++i;
                            comment=1;
                            break;
                        }
                        ++brakets;
                        continue;
                    }
                    if(syms[i]==')')
                    {
                        ++i;
                        --brakets;
                        if(!brakets)
                        {
                            arithmetical=0;
                            break;
                        }
                    }
                    ++i;
                }
                continue;
            }
            while(syms[i])
            {
                if(syms[i]=='(')
                {
                    ++i;
                    if(syms[i]=='*')
                    {
                        ++i;
                        comment=1;
                        break;
                    }
                    arithmetical=1;
                    ++brakets;
                    break;
                }
                if(syms[i]==')')
                {
                    printf("NO");
                    return;
                }
                ++i;
            }
        }
    }
    if(arithmetical||comment)
    {
        printf("NO");
        return;
    }
    printf("YES");
}
WHY WA1?!
Re: WA1
Послано Gelioscope 25 июн 2011 00:55
Give me solution for this task, please, i don't understand why i get WA#1