1601. Anticaps
Time limit:0.5 Second
Memory limit:64 MB
The blonde Angela has a new whim:internet chats. Of course, as any blonde, shewrites she messages using the upper case. You're the moderator of Angela ' sfavorite chat and you ' re-fed up with her upper-case messages. The problemis that Angela does isn't respond to your warnings. You decided to write a simpleanticaps corrector, which would make Angela ' s messages readable. The correction rules is very simple:
- Sentences in a message consist of words, spaces and punctuation marks.
- Words consist of 中文版 letters.
- Sentences end with a full stop, exclamation mark, or question mark.
- The first word of each sentence must start with a capital letter, and all otherletters of the sentence must is lowercase.
Inputyou is given Angela's message, which consists of uppercase 中文版 letters,spaces, line breaks and punctuation marks : Full stops, commas, dashes, colons, exclamationand question marks. Total length of message was not exceeding 10000 symbols. Outputoutput the corrected message. Sample
input |
Output |
HI there! How do you KNOW I AM A blonde? |
Hi there! How do you know I am a blonde? |
problem Author:Denis Musin
problem Source:IX USU Open Personal Contest (March 1, 2008)
Resolution: note two points:
1. Each sentence with '. ', '? ' AND '! End Each sentence begins with uppercase characters.
2. Line break does not count as the end of the sentence.
Two sets of sample samples are provided below:
INPUT1:
HELLO. I AM anjela! And you?
I AM Blonde.
OUTPUT1:
Hello. I am anjela! And you?
I am Blonde.
Input2:
Hhhhhhhhhh? sdsdfsdf! Sfsdf. Sdfaf
Hkllksdjoi
Output2:
Hhhhhhhhhh? sdsdfsdf! sfsdf. SDFAF
Hkllksdjoi
AC Code:
#include <bits/stdc++.h>using namespace Std;int main () { #ifdef sxk freopen ("In.txt", "R", stdin); #endif//Sxk string s; int flag = 1; while (Getline (CIN, s)) { int n = s.size (); for (int i=0; i<n; i++) { if (flag) { if (s[i] >= ' A ' && s[i] <= ' Z ') flag = 0; } else{ if (s[i] >= ' A ' && s[i] <= ' Z ') s[i] + = (' A '-' a '); else if (s[i] = = '. ' | | s[i] = = '? ' | | s[i] = = '! ') flag = 1; } } cout<<s<<endl; } return 0;}
URAL 1601. Anticaps (Strings)