[2017-2018 on software Engineering] string, array exercises

Source: Internet
Author: User

One or two-D arrays

Computes the sum of all array elements in an 3x4 array that are greater than or equal to the average, and counts the number of elements that satisfy the condition. The average value in the subject is a decimal, and all other variables used are integral types.

Input format:

Enter a matrix of 3 rows and 4 columns, with no spaces before the first number in each row, and a space between each number of each row.

Output format:

In a row according to the "s= and, n= number" in the order of output, the results are output, no column width control.

Input Sample:

1 4 7 82 1 4 21 2 3 4

Sample output:

s=27,n=5
Second, data structure

The main requirement is to write a program that first exchanges the minimum value in a series of integers with the first number, then swaps the maximum value with the last number, and finally outputs the switched sequence.

Note: The title guarantees that the maximum and minimum values are unique.

Input format:

The input gives a positive integer n (≤10) in the first row, the second line gives n integers, and the numbers are separated by spaces.

Output format:

Sequentially outputs the swapped sequence in a row, followed by a space after each integer.

Input Sample:

58 2 5 1 4

Sample output:

1 2 5 4 8
Three, string

The subject requires a program to replace the uppercase letters in the given string with the following corresponding rules:

原字母     对应字母A           ZB           YC           XD           W…           …X           CY           BZ           A

Input format:

Enter a string that is not more than 80 characters in a row and ends with a carriage return.

Output format:

The output gives a string after the replacement is completed in a row.

Input Sample:

Only the 11 CAPItaL LeTtERS are replaced.

Sample output:

Lnly the 11 XZKRtaO OeGtVIH are replaced.
Four, string

The subject requires the program, to a "#" end of the string, its lowercase letters all converted to uppercase, all uppercase letters to lowercase letters, other characters do not change output.

Input format:

Enter as a string that ends with "#" (no more than 30 characters).

Output format:

Outputs the case-converted result string in a row.

Input Sample:

Hello World! 123#

Sample output:

hELLO wORLD! 123

[2017-2018 on software Engineering] string, array exercises

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.