plz help me.i have wrong ans in this problem

General topic about Valladolid Online Judge

Moderator: Board moderators

Locked
tanin
New poster
Posts: 1
Joined: Mon Jul 09, 2007 3:46 pm

plz help me.i have wrong ans in this problem

Post by tanin »

#include<stdio.h>

int main(void)
{
int i,j,k;
char s[100];
gets(s);
for(i=0 ; s ; i++)
{
if(s==' ')
{
for(k=i;s[k];k++)
{
s[k]=s[k+1];
}
}
else
{
int count=1;
for(j=i+1 ; s[j] ; j++)
{
if(s[j]==' ')
{
for(k=j;s[k];k++)
{
s[k]=s[k+1];
}
}
if(s==s[j])
{
count++;
for(k=j;s[k];k++)
{
s[k]=s[k+1];
}
j=j-1;
}
}
printf("%c %d\n",s,count);
}
}
return 0;
}

nymo
Experienced poster
Posts: 149
Joined: Sun Jun 01, 2003 8:58 am
Location: :)

Post by nymo »

tanin, please do NOT open a new thread when there is one. you have not specified the number or name of the problem, so, I hardly think anyone can help. anyway, USE search button on top, use problem number or name whatever you find useful as keyword. hope you find some help then.
regards,
nymo

Locked

Return to “General”