12405

All about problems in Volume CXXIV. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

12405

Postby riazur_cse » Sun Jan 08, 2012 2:26 pm

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

int main()
{
char inp[500];
int test,i,k,cnt,t,n,j;
char ch;
scanf("%d",&test);
for(t=1;t<=test;t++)
{
memset(inp,0,sizeof(inp));
scanf("%d",&n);
scanf("%s",&inp);
cnt=0;
for(i=0;i<n;i++)
{
if(inp[i]=='.' || inp[i]=='#')
{
if((inp[i-1]=='.' && i>=0) && (inp[i+1]=='.' && i<n))
{
inp[i]='1';
inp[i-1]='1';
inp[i+1]='1';
cnt++;
}
}
}
for(i=0;i<n;i++)
{
if(inp[i]=='.')
{
if((inp[i-1]=='.' && i>=0))
{
inp[i]='1';
inp[i-1]='1';
cnt++;
}
else if((inp[i+1]=='.' && i<n))
{
inp[i]='1';
inp[i+1]='1';
cnt++;
}
else
{
cnt++;
}
}
}
printf("Case %d: %d\n",t,cnt);
}
return 0;
}

pls check whtz wrng with this one....I dont understand.
Thanks..
riazur_cse
New poster
 
Posts: 2
Joined: Sun Jan 08, 2012 4:38 am

Re: 12405

Postby robot » Tue Jan 10, 2012 9:36 am

Hello, try this input...
I think ur code does not work for this input..think easily, its a easy problem
2
10
..#..##...
13
..#..##....#.

out:
Case 1: 3
Case 2: 4

ASU(SUST) :)
robot
New poster
 
Posts: 29
Joined: Sun May 24, 2009 8:39 pm


Return to Volume CXXIV

Who is online

Users browsing this forum: No registered users and 0 guests