|
|
вернуться в форумReading strings on C++ Strange. It's already second prob., wich got WA #1, where I've got to read strings from input. FE, in this prob., I used two methods reading word in the end of line (all tests, I tested my solution were correct): cin.getline(ss,sizeof(ss)); s.assign(ss); while (s[0] == ' ') s.erase(s.begin()); while (s[s.length()-1] == ' ') s.erase(s.begin() + s.length() - 1); if (s == "odd") p[i] = 1; else p[i] = 0; And the second one: scanf("%s",ss); if (ss[0] == 'o') p[i] = 1; else p[i] = 0; Both got WA #1. Am I wrong? Edited by author 06.01.2006 09:56 Re: Reading strings on C++ As I can see now, this prob. is kind of stupid. Everyone got WA #1. Or bug was fixed? Re: Reading strings on C++ hi guy this program may help you:) #include <iostream> #include <iomanip> #inlcude <string> using namespace std; int main() { string aStr; getline(cin,aStr); cout<<aStr<<endl; getline(cin,aStr,"\n"); cout<<aStr<<endl; } |
|
|