Huawei device trial-remove the maximum and minimum values and then the remaining number. Huawei minimum values

Source: Internet
Author: User

Huawei device trial-remove the maximum and minimum values and then the remaining number. Huawei minimum values

Enter a string of numbers separated by commas (,), and remove the remaining number after the maximum and minimum values of all output numbers. (The maximum and minimum values may have multiple values)


Sample input: 3, 3, 5, 3, 6, 9, 7, 9

Sample output: 3


# Include <stdio. h>/* solution: Use strtok to split the string, calculate the maximum and minimum number, traverse the array, and calculate the number of the maximum and minimum numbers */# include <stdlib. h> # include <string. h> int main (int argc, char * argv []) {char s [100]; int a [100]; int I = 1; fgets (s, 100, stdin); char * p = strtok (s, ","); int start = atoi (p); a [0] = start; int _ min = start; int _ max = start; while (p = strtok (NULL, ",") {int t = atoi (p); if (t> _ max) _ max = t; if (t <_ min) _ min = t; a [I ++] = t;} int count = 0; for (int j = 0; j <I; ++ j) {if (a [j]! = _ Max & a [j]! = _ Min) count ++;} printf ("% d \ n", count); return 0 ;}

Test data: 3,3, 5,3, 6,9, 7,9

Test results:


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.