Input a set of data and store it in the array, and dynamically complete the number of data elements by the input function. Find the maximum value and minimum value of the input data, and return the result through the function parameters_I don’t want to be bald o(^o^)o’s blog

class=”markdown_views prism-atom-one-dark”> Input a set of data and store it in the array, and dynamically complete the number of data elements by the input function. Find the maximum value and minimum value of the input data, and return the result through the function parameter; Problem Analysis: Input a set of data and store it in an array, and the dynamic input of data indicates the need for dynamic space allocation (the use of pointers, the use of malloc, and the use of free functions), and to find the maximum and minimum values, you may need to use for loops and if statements judge; //Enter a set of data and put it in the array, the number of data elements is dynamically completed by the input function, //Find the maximum value and minimum value of the input data, and return the result through the function parameter #include #include int* DyArray(int **pDyArray,int n) { *pDyArray=(int*)malloc(n*sizeof(int)); return *pDyArray; } void InputDyArray(int *pDyArray,int n ) { int i; for(i=0;in;i++) { printf(“please input number %d: “,i); scanf(“%d”,&pDyArray[i]); } return; } void MaxMin(int *pDyArray,int n ,int *Max,int *Min) { int i; *Max=*pDyArray; *Min=*pDyArray; for(i=1;in;i++) { if(*MaxpDyArray[i]) { *Max=pDyArray[i]; } if(*Min>pDyArray[i]) { *Min=pDyArray[i]; } } return; }…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索