URAL 1601. Anticaps (Strings)

Source: Internet
Author: User

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:
    1. Sentences in a message consist of words, spaces and punctuation marks.
    2. Words consist of 中文版 letters.
    3. Sentences end with a full stop, exclamation mark, or question mark.
    4. 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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.