Saturday 5 May 2012

UVa 272 TeX Quotes Solution

#include<stdio.h>
#include<string.h>
int main()
{
long int i,count=0,l;
char s[100000];
while(gets(s))
{
l=strlen(s);
for(i=0;i<l;i++)
    {
    if(s[i]=='"')
        {
        count=count+1;
        if(count%2==1)
            printf("``");
        else
            printf("''");
        }
    else
        printf("%c",s[i]);
    }
printf("\n");
}
return 0;
}

5 comments:

  1. Can you please explain for me about "strlen" function.and also something about please.

    ReplyDelete
  2. strlen used to measure the string size

    ReplyDelete
  3. may be (long int)is not necessary . only int key is enough.

    ReplyDelete