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 1404. Easy to Hack!

WA 14, help please!
Posted by Smusenok Sergiy Andriyovich (KhAI) 13 Aug 2009 04:08
please give some test

#include <stdio.h>
int main()
{
    int string[200];
    int len=0;
    char ch;
    int count;
    ch=getchar();
    while(!((ch=='\0')||(ch=='EOF')||(ch=='\n')))
    {
        string[len]=ch-'a';
        len++;
        ch=getchar();
    }
    string[len]='\0';
    //perviy prohod
    if(len==1)
    {
        printf("%c\0",string[0]-5);
        return 0;
    }
    if (string[0]<5)
        string[0]+=26;
    for(count=1;count<len;count++)
    {
        while(string[count]<string[count-1])
            string[count]=string[count]+26;
    }
    //vtoroy prohod
    for(count=len-1;count>0;count--)
    {
        string[count]=string[count]-string[count-1];
    }
    string[0]=string[0]-5;
    //tretiy prohod
    for(count=0;count<len;count++)
    {
        printf("%c",string[count]+'a');
    }
    printf("\0");
    return 0;
}
Re: WA 14, help please!
Posted by Smusenok Sergiy Andriyovich (KhAI) 13 Aug 2009 04:15
i find my mistake. don't forget about case,when you have 1 symbol!
/////////////WA 14//////////
if(len==1)
{
printf("%c\0",string[0]-5);
return 0;
}
///////////////AC////////////
if(len==1)
{
if (string[0]<5)
string[0]+=26;
printf("%c\0",string[0]-5+'a');
return 0;
}