Array Maximum Value

Source: Internet
Author: User

Design ideas:

1. Structure function function

2. Maximum value assigned to the first number of arrays

3. Loop compares the other numbers of the array to the size of the first number and assigns the large to Max

4. Main function Call function

5. Output

SOURCE program code:

#include <iostream>using namespace Std;int largest (int length,int list[]) {    int i,max=list[0];    For (i=0;i<= (length-1); i++)    {        if (List[i]>max)        {            max = list[i];        }    }    return Max;} int main () {    int lis[5];    cout<< "Please enter 5 numbers" <<endl;    for (int i=0;i<5;i++)    {        cin>>lis[i];    }    cout<< "Maximum value is" <<largest (5,lis) <<endl;}

Results:

1. It's all positive.

2. It's all negative.

3. There is a positive negative

4. Have the same number

5. Have the same two maximum number

Array Maximum Value

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.