|
|
back to boardwrong answer #1 Posted by Dejust 26 Feb 2011 21:32 Re: wrong answer #1 Posted by Dejust 27 Feb 2011 15:45 my code: #include <string> #include <iostream> using namespace std; int main() { string line; getline(cin, line); static bool sing = false; for(int i = 0; i < line.length(); i++) { if(sing) { if((line[i] >= 'A') && (line[i] <= 'Z')) { char temp = line[i] - ('A'-'a'); cout << temp; } else if((line[i] == '.') || (line[i] == '!') || (line[i] == '?')) { cout << line[i]; sing = false; } else if(line[i] == 10 || line[i] == 26) { cout << '\n'; } else { cout << line[i]; } } else { if(line[i] >= 'A' && line[i] <= 'Z') { cout << line[i]; sing = true; } else if(line[i] == 10 || line[i] == 26) { cout << '\n'; } else if((line[i] == '.') || (line[i] == '!') || (line[i] == '?')) { cout << line[i]; } else { cout << line[i]; } } } return 0; } Re: wrong answer #1 Cause your first char is lower? but it should be upper.. |
|
|