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: