[Huawei machine trial exercise questions] 16. Digital statistics, Huawei exercises

Source: Internet
Author: User

[Huawei machine trial exercise questions] 16. Digital statistics, Huawei exercises

Question

Title: for the input integer array, the number of maximum, maximum, minimum, and minimum values in the output array element. Detailed Description: Interface Description prototype: voidOutputMaxAndMin (int * pInputInteger, intInputNum, int * pMaxValue, int * pMaxNum, int * pMinValue, int * pMinNum); input parameter: Int * pInputInteger: integer array pointer Int InputNum: output parameter of the number of array elements (the memory area pointed to by the pointer is valid): int * pMaxValue: Maximum Value in the array int * pMaxNum: Maximum number in the array int * pMinValue: minimum int * pMinNum in the array: Number of minimum values in the array return value: void involves knowledge points: C language basics: array, comparison performance requirements: No lap Complexity Requirements: This is not provided by the problem, the global configuration of the subsequent judgment system is as follows: code projects and use cases such as function circle complexity less than 10 and class public functions less than 20: C/C ++: CPPUNIT use case knowledge of VS2005 Code project embedded project: Use VS2005 project environment Source: software training camp maintainer: d00191780 exercise stage: elementary

Code

/* ------------------------------------- * Date: 2015-06-30 * Author: SJF0115 * Subject: Digital Statistics * Source: Huawei computer ----------------------------------------------- */# include <St. h>/* function: for the input integer array, input: int * pInputInteger: int * InputNum: number of array elements output: int * pMaxValue: Maximum Value in the array int * pMaxNum: Maximum number in the array int * pMinValue: Minimum value in the array int * pMinNum: minimum number in the array returns: void */void OutputMaxAndMin (int * pInputInteger, int InputNum, int * pMaxValue, int * pMaxNum, int * pMinValue, int * pMinNum) {if (pInputInteger = NULL | InputNum <= 0) {return ;}// if * pMaxValue = pInputInteger [0]; * pMinValue = pInputInteger [0]; * pMaxNum = 1; * pMinNum = 1; for (int I = 1; I <InputNum; ++ I) {// update the maximum value if (pInputInteger [I]> * pMaxValue) {* pMaxValue = pInputInteger [I]; * pMaxNum = 1;} // if else if (pInputInteger [I] = * pMaxValue) {++ (* pMaxNum );} // else // update the minimum value if (pInputInteger [I] <* pMinValue) {* pMinValue = pInputInteger [I]; * pMinNum = 1 ;} // if else if (pInputInteger [I] = * pMinValue) {++ (* pMinNum) ;}// else} // for return ;}

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

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.