Tuesday 17 May 2011

272-Text Quotes

#include <stdio.h>
int main()
{
    char chr;int check=0;
    //freopen("in.txt","r",stdin);
    while(scanf("%c",&chr)==1)
    {
            if(chr!='"')
                printf("%c",chr);
            else
            {
                if((++check) & 1) /*Increament and check even or odd at the same time*/
                {
                    printf("``");
                }
                else
                    printf("''");
            }
            if(chr=='.')
                check=0;
    }
    return(0);
}

No comments:

Post a Comment