1#include <iostream>2 using namespacestd;3 intLargest (intList[],intlength);//list[]: function to find the maximum value,4 intMain ()5 {6 intlist[ -];//an array of length 1007 intlenght;8 inti; 9cout <<"Please enter the length of the one-dimensional array:";TenCin >> Lenght;//Input Array Length One if(Lenght = =0)//consider that the length of the array cannot be 0 A { -Cerr <<"the array length cannot be zero!! "<<Endl; - return 0; the } -cout <<"Please enter"<< Lenght <<"an integer:"; - for(i =0; I < lenght; i++) - { +CIN >> List[i];//Enter array values and calculate the maximum number of groups - } +cout <<"The maximum value for this array is:"<< largest (list, lenght) << Endl;//largest (List,lenght): Indicates the maximum value A return 0; at } - intLargest (intList[],intLength//to find the maximum value of this array - { - intI, max = list[0]; - for(i =1; i < length; i++) - { in if(List[i] >max) - { toMax =List[i]; + } - } the returnMax; *}
Design ideas: Array size cannot be 0, directly input array data, to find the maximum value
Experiment:
Design schedule:
Event |
Time period |
Time |
Date |
Design ideas |
10:00-10:45 |
45m |
April 9 |
Find information |
7:00-7:30 |
30m |
April 10 |
Ask your classmates |
7:30-8:30 |
1h |
|
Translation Program |
8:30-900 |
30m |
|
Summarize |
9:00-9:30 |
30m |
|
Summary: Understand part of the content, if done more, will naturally extrapolate, sure enough, pay will have harvest.
Max Value-Unit test