06-2. case-insensitive conversion of string letters (10)

Source: Internet
Author: User

Enter a string ending with #. This question requires that all lowercase letters be converted to uppercase letters, and all uppercase letters be converted to lowercase letters. Other characters remain unchanged.

Input Format:

Enter a non-null string with a length not greater than 40 and ended with # in a row.

Output Format:

Output the converted string in one line as required.

Input example:

Hello World! 123#

Output example:

hELLO wORLD! 123



 1 #include <stdio.h> 2  3 int main() 4 { 5     char s[40]; 6     int i = 0; 7     do { 8         scanf("%c", &s[i]); 9         i++;10     } while(s[i-1] != ‘#‘);11     int j;12     for(j = 0; j < i-1; j++) {13         if(s[j] >= ‘a‘ && s[j] <= ‘z‘) {14             s[j] -= 32;15         }16         else if (s[j] >= ‘A‘ && s[j] <= ‘Z‘) {17             s[j] += 32;18         }19     }20     for(i = 0; i < j; i++) {21         printf("%c", s[i]);22     }23     24     return 0;25 }

 

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.