Page 2 of 4
I'm confused!
Posted: Tue Oct 26, 2004 6:59 am
by yellow
Everything is okie on my VC++, but I get the compile error everytime i submit the code:
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
char line[200];
int numSyl[]={5,7,5}; //array of correct number of syllables (5/7/5)
cin.getline(line,'/n');
while (strcmpi(line,"e/o/i")) //check for end of file
{
int j=0;
int i=0;
bool allCorrect = true;
//check if the prvious character is a syllable
while(j<3)
{
int count=0;
bool flag=false;
//count number of syllables in each sentence
while(line!='/'&&line!=NULL)
{
if(line=='a'||line=='e'||line=='i'||line=='o'||line=='u'||line=='y')
{
if(flag==false)
{
count++;
flag=true;
}
}
else
flag=false;
i++;
}
i++;
if (count!=numSyl[j])
{
allCorrect = false;
cout<<(j+1);
break; //break the loop if one of the sentence has wrong number of syllables
}
j++;
}
if (allCorrect)
cout<<'Y';
cout<<endl;
cin.getline(line,'/n');
}
return 0;
}
Posted: Tue Oct 26, 2004 8:29 am
by wirjawan
Mohammad Mahmudur Rahman wrote:I think the
strcmpi in your code is causing the problem. Note that strcmpi is valid neither in ANSI C nor in UNIX. To avoid CE (though I myself have recieved 80 CEs to date

), remember that judge uses UNIX system to compile your program.
instead of strcmpi, use strcmp (make sure you #include <string.h>)
you might also want to fix the warnings below =)
[cpp]
cin.getline(line,'/n');
[/cpp]
to:
[cpp]
cin.getline(line,200,'\n'); /* 200 is the size of the buffer */
[/cpp]
and also
[cpp]
while(line
!='/'&&line!=NULL)
[/cpp]
to:
[cpp]
while(line!='/'&&line!='\0')
[/cpp]
hope this helps
Posted: Wed Oct 27, 2004 2:24 am
by yellow
Greats!!! You really help me out, thanks a lot!
576 getting WA???
Posted: Mon Jan 10, 2005 8:06 am
by Fuad Hassan_IIUC(DC)
I have tried with more than 7 critical inputs, all showed the correct answers but still i am getting wrong answer!!!!!

plz help me out of this problem.
Posted: Mon Jan 31, 2005 8:23 pm
by Fuad Hassan_IIUC(DC)
plz help me

Posted: Wed Feb 02, 2005 7:53 pm
by Fuad Hassan_IIUC(DC)
I got AC thank you

Posted: Sat Jun 04, 2005 7:18 pm
by liang1425
I tested all the above test cases,and it's correctly.
But I still got WA.
Please help me.
Thanks a lot.
Posted: Sat Jun 04, 2005 8:34 pm
by Mohammad Mahmudur Rahman
Just change
to
While working with strings, never forget to allocate space for the Null terminating character. I think there's no other error in your program.
Posted: Sun Jun 05, 2005 11:33 am
by liang1425
Thank you

576- haiku review
Posted: Thu Jan 12, 2006 6:29 pm
by abhi
here is my code. it got AC in 0.002 sec. but there are soooo many users with 0.000. plz tell me where i can optimize the code. i am still a beginner .....i want to get AC in 0.000
[codedeleted[/code]
Posted: Thu Jan 12, 2006 8:03 pm
by mamun
My friend, you are posting an accepted solution!
0.000 and 0.002 isn't of much difference. If you are lucky then you'll get 0.000 after submitting 2/3 times, if not earlier.
Posted: Fri Jan 13, 2006 4:39 am
by abhi
i know that its not too much of a difference .......but still i would like to know y i got AC in 0.002 whereas many got AC in 0.000 in only their 1st attempt ????? y is it that i should submit 2 or 3 times whereas they get it AC on 0.000 in their 1st attempt only ????

Posted: Fri Jan 13, 2006 8:50 am
by mamun
For those which you get runtime of 0.000 will mostly get in your first attempt. But sometimes it happens that you get it 0.002 and another attempt you get it in 0.000.
576 Haiku Review WA!!!
Posted: Thu Feb 23, 2006 8:56 am
by tmdrbs6584
#include<iostream.h>
#include<string.h>
char a[201];
int main(){
int z,x;
while(cin.getline(a,201)){
int len=strlen(a),i;
if(len==5 && a[0]=='e' && a[1]=='/' && a[2]=='o' && a[3]=='/' && a[4]=='i') break;
int cnt1=0,cnt2=0,cnt3=0;
for(i=0;i<len;i++){
if(a=='/') z=i;
}
for(i=0;i<len;i++){
if(i==z) continue;
if(a=='/') x=i;
}
for(i=0;i<x;i++){
if(a=='a' || a=='e' || a=='i' || a=='o' || a=='u' || a=='y') cnt1++;
}
if(cnt1==5){
for(i=x+1;i<z;i++){
if(a=='a' || a=='e' || a[i]=='i' || a[i]=='o' || a[i]=='u' || a[i]=='y') cnt2++;
}
if(cnt2==7){
for(i=z;i<len;i++){
if(a[i]=='a' || a[i]=='e' || a[i]=='i' || a[i]=='o' || a[i]=='u' || a[i]=='y') cnt3++;
}
if(cnt3==5) cout << "Y" << endl;
else cout << 3 << endl;
}
else cout << 2 << endl;
}
else cout << 1 << endl;
}
return 0;
}
WHY WA?????????
Posted: Wed Mar 15, 2006 8:14 am
by emotional blind
your algorithm is not right
think about some word like