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 1226. esreveR redrO

WA# 10. please help!
Posted by Smusenok Sergiy Andriyovich (KhAI) 14 Aug 2009 04:51
my code
////////////////////////////////
#include <stdio.h>
int main()
{
    char string[1000000];
    int len=0;
    char ch;
    int count=0;
    int i;
    char temp;
    int nachalo=-1;
    int konec=-1;
    ch=getchar();
    while(ch!=EOF)
    {

        string[len]=ch;
        len++;
        ch=getchar();
    }
    for(count=0;count<len;count++)
    {
        if(nachalo<0)
            if(((string[count]<='z')&&(string[count]>='a'))||((string[count]<='Z')&&(string[count]>='A')))
                nachalo=count;

        if(nachalo>-1)
            if(!(((string[count]<='z')&&(string[count]>='a'))||((string[count]<='Z')&&(string[count]>='A'))))
                konec=count-1;
        if (konec>-1)
        {
            for(i=nachalo;i<=nachalo+(konec-nachalo)/2;i++)
            {
                temp=string[i];
                string[i]=string[konec-i+nachalo];
                string[konec-i+nachalo]=temp;
            }
            nachalo=-1;
            konec=-1;
        }

    }
    for(i=0;i<len;i++)
        printf("%c",string[i]);

    return 0;
}

Edited by author 14.08.2009 04:52
Re: WA# 10. please help!
Posted by Sergey Lazarev (MSU Tashkent) 14 Aug 2009 10:52
Your program doesn't work if the last symbol is any English letter, because there is no its "konec".