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 1089. Verification with the Dictionary

why WA#7??? Give me test!!!
Posted by tester 28 Oct 2009 21:30
#include <stdio.h>
#include <string.h>

struct problem_1089
{
    char word[10];
    int len;
};

problem_1089 slovar[100] = {};
int n = 0;
bool flag = false;
char c;
char str[1001] = {};
int len = 0;
int count = 0;

void check()
{
    for (int i = 0; i < n; i++)
    {
        if (slovar[i].len == len)
        {
            int error = 0;
            for (int j = 0; j < len; j++)
            {
                if (str[j] != slovar[i].word[j]) error++;
                if (error > 1) break;
            }
            if (error == 1)
            {
                strcpy (str,slovar[i].word);
                count++;
                return;
            }
        }
    }
    return;
}

int main ()
{
    //freopen ("input.txt","r",stdin);
    //freopen ("output.txt","w",stdout);
    while (!flag)
    {
        gets(slovar[n++].word);
        slovar[n - 1].len = strlen (slovar[n - 1].word);
        if (strcmp(slovar[n - 1].word,"#") == 0)
        {
            flag = true;
            slovar[--n].word[0] = '\0';
            slovar[n].len = 0;
        }
    }
    bool perevod = false;
    while (scanf ("%c", &c) != EOF)
    {
        flag = false;
        if (c > 96 && c < 123)
            str[len++] = c;
        else
        {
            check();
            for (int i = 0; i < len; i++) printf ("%c", str[i]);
            if (c == '\n') perevod = true;
            else perevod = false;
            printf ("%c", c);
            len = 0;
        }

    }
    if (len > 0) perevod = false;
    check();
    for (int i = 0; i < len; i++) printf ("%c", str[i]);
    if (!perevod && !flag) printf ("\n%d", count);
    else printf ("%d", count);
    return 0;
}
Re: why WA#7??? Give me test!!!
Posted by Varun Sharma 2 Nov 2009 04:10
Hi,

There can be more than 100 words in the vocabulary so don't read just first 100 words instead just read everything till you encounter #

Varun