ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1601. AntiCAPS

Why WA#4 C++
Posted by Burdin Artyom`~ 16 Aug 2018 17:57
#include <bits/stdc++.h>

using namespace std;

int main()
{
    string s;
    int pe = 0;
    while(getline(cin, s)) {
        for (int i = 0; i < s.length(); i++) {
            if (s[i] == '.' || s[i] == '!' || s[i] == '?' || (s[i] == '-' && i )) {
                pe = 0;
            }
            if ((s[i] - '0' + '0' >= 65 && s[i] - '0' + '0' <= 90) && pe != 0) {
                s[i] = s[i] - '0' + 32 + '0';
            }
            if (pe == 0 && s[i] != ' ' && s[i] != '.' && s[i] != '!' && s[i] != '?' && s[i] != '-') {
                if (s[i] - '0' + '0' > 90) {
                    s[i] = s[i] - '0' - 32 + '0';
                }
                pe = 1;
            }
        }
        cout << s << '\n';
    }
}

Edited by author 16.08.2018 18:05

Edited by author 16.08.2018 18:05
Re: Why WA#4 C++
Posted by Burdin Artyom`~ 16 Aug 2018 18:07
Ohhhhh..... I find my wrong...

-HI
- HI

WA:

-Hi
- Hi

AC:

-Hi
- hi