用delphi编写函数求一个数组中的最大值和最小值

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用delphi编写函数求一个数组中的最大值和最小值相关的知识,希望对你有一定的参考价值。

急求,谢谢各位了哪位高手帮下忙

参考技术A //求最大值
function GetMaxInArray(A: array of Integer): Integer;
var
I: Integer;
tmpMax: Integer;
begin
tmpMax := A[0];

for I := low(A) to High(A) do
begin
if A[I] > tmpMax then tmpMax := A[I];
end;

Result := tmpMax;
end;

//求最小值
function GetMinInArray(A: array of Integer): Integer;
var
I: Integer;
tmpMin: Integer;
begin
tmpMin := A[0];

for I := low(A) to High(A) do
begin
if A[I] < tmpMin then tmpMin := A[I];
end;

Result := tmpMin;
end;

C语言利用指针编写程序,求一维数组中的最大和最小值

#include<stdio.h>
//利用指针编写程序,求一维数组中的最大和最小值
int main()
 int a[10],i;
 for(i=0;i<10;i++)
  scanf("%d",&a[i]);
 int max,min,*p;
 p=a;
 max=min=a[0];
 for(;p<a+10;p++)
 
  if(*p>max)
   max=*p;
  if(*p<min)
   min=*p;
 
 printf("max=%d,min=%d",max,min);
 return 0; 

以上是关于用delphi编写函数求一个数组中的最大值和最小值的主要内容,如果未能解决你的问题,请参考以下文章

python编写程序,利用元组作为函数的返回值,求系列类型的最大值、最小值和元素个数

设计函数实现求数组中的最大值,用该函数计算某班级学生的最高分.C语言

delphi 如何对动态数组求和(INT型),求最大值和最小值

ios 快速获取数组中的最大值、最小值

C语言中怎样用指针找出一维数组中的最大值和最小值并输出它们的下标

Java泛型,返回数组最大值最小值