why WA in 494?!!

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

Moderator: Board moderators

why WA in 494?!!

Postby tanvirfromhell » Thu Apr 28, 2011 11:32 am

//why I got WA for this code?!!! plz help me.

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int count=0;
char a[1000000];
char *p;
while(gets(a))
{
count=0;
p=strtok(a," !.");
while(p!=NULL)
{
p=strtok(NULL," !.");
count++;
}
printf("%d\n",count);
}
return 0;
}
tanvirfromhell
New poster
 
Posts: 5
Joined: Sat Apr 16, 2011 7:42 pm

Re: why WA in 494?!!

Postby sohel » Fri Apr 29, 2011 12:44 am

Use the search option located at the top right corner to find existing discussions.
Don't create a new thread for a problem that already exists! Make your post on an existing thread.
User avatar
sohel
Guru
 
Posts: 862
Joined: Thu Jan 30, 2003 5:50 am
Location: University of Texas at San Antonio

Re: why WA in 494?!!

Postby plamplam » Wed May 25, 2011 6:18 pm

I don't see any problem with your code....except for the part p=strtok(NULL," !.");....I don't have the test cases but don't you think its possible to give more punctuations like ' or ( ) or & or @ or ?. So just find a way to exclude every possible punctuations and stuff. Hint : Just include all the upper-case and lower-case chars then every other chars are automatically eliminated. Good luck
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson
User avatar
plamplam
Experienced poster
 
Posts: 151
Joined: Fri May 06, 2011 11:37 am

Re: why WA in 494?!!

Postby bristy1588 » Mon Jan 30, 2012 12:03 pm

If there is something like mom's. is it a word?
bristy1588
New poster
 
Posts: 2
Joined: Sun Jan 29, 2012 12:09 pm

Re: why WA in 494?!!

Postby sohel » Mon Jan 30, 2012 10:18 pm

mom's has two words - mom and s.
User avatar
sohel
Guru
 
Posts: 862
Joined: Thu Jan 30, 2003 5:50 am
Location: University of Texas at San Antonio


Return to Volume IV

Who is online

Users browsing this forum: No registered users and 0 guests