here are part of your code:
AaronWu wrote:[cpp]
cin>>n;
.
.
gets(chs);
[/cpp]
they are correct, but differ from
gets(), when you use these two, they will left a '\n' in the input stream('cause they only see the number before it). after then, you use
gets(), and it see this '\n' and get it back for the first string, which will be a empty string. since this problem should run when empty string entered, you get "Yes" before your first input every time you run, so it resulted to WA.
using
gets() instead of these two method will read in the '\n' (though
gets() didn't put it into your string).you can use
atoi() or
sscanf() to read the number you want from the string just read.
hope these will explain your question
