Timus 1601. anticaps

Source: Internet
Author: User
Timus 1601. anticaps requires that the text of an upper-case English letter be converted to an appropriate lower-case English letter.
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, she
Writes her messages using the upper case. You are the moderator of Angela's
Favorite chat and you're fed up with her upper-case messages. The problem
Is that Angela does not respond to your warnings. You decided to write a simple
Anticaps corrector, which wocould make Angela's messages readable.

The correction rules are very simple:

  1. Sentences in a message consist of words, spaces and punctuation marks.
  2. Words consist of English 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 other
    Letters of the sentence must be lowercase.
Input

You are given Angela's message, which consists of uppercase English letters,
Spaces, line breaks and punctuation marks: full stops, commas, dashes, colons, exclamation
And question marks. Total length of message is not exceeding 10000 symbols.

Output

Output the corrected message.

Sample
Input Output
Hi there!
How did you know I am a blonde?
Hi there!
How did you know I am a blonde?

Problem Author:Denis musin
Problem Source:Ix usu open personal contest (March 1, 2008)

The answer is as follows (C # language ):

1 using system;
2
3 namespace skyiv. Ben. timus
4 {
5 sealed class t1601
6 {
7 static void main ()
8 {
9 int V;
10 bool iscap = true;
11 while (V = console. In. Read ())! =-1)
12 {
13 char c = (char) V;
14 if (C = '.' | C = '! '| C = '? ') Iscap = true;
15 else if (iscap & char. isupper (c) iscap = false;
16 else if (! Iscap & char. isupper (c) c = Char. tolower (C );
17 console. Write (C );
18}
19}
20}
21}

The C language version is as follows:

1 # include <stdio. h>
2
3 int main ()
4 {
5 Int C, iscap = 1;
6 While (C = getchar ())! = EOF)
7 {
8 If (C = '.' | C = '! '| C = '? ') Iscap = 1;
9 else if (iscap & isupper (c) iscap = 0;
10 else if (! Iscap & isupper (c) c = tolower (C );
11 putchar (C );
12}
13}

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.