Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

attic problem cook off june .

$
0
0

can someone please tell me why my code was giving WA ?

#include<stdio.h>
#include<string.h>



int main()
{
    int times,i,k,sum=0;   
    scanf("%d",&times);
    for( i=0;i<times;i++)
    { 
         char p[1000000];   
        int j=0,longest=0,result=0;

        scanf("%s",p);
    //  printf("%s\n",p);
    //  printf("strlen%d\n",strlen(p));
    //  while(p[j]!='\0')



       for(j=0;j<strlen(p);j++)
        {

            if(p[j]=='.')
            {sum=0;
                for( k=j;p[k]!='#';k++)
                {
                    sum++;                
                }           
                if(sum>longest)             
                {
                longest=sum;                
                result++;
                }

            }


        }




    printf("%d\n",result);

    }


    return 0;
}

Viewing all articles
Browse latest Browse all 39796

Trending Articles