php用for循环求数组最大值 怎么用for循环计算数组最大值?代码怎么写?

怎么用for循环计算数组最大值?代码怎么写?两个例子希望对你的问题有所帮助(VB):1。随机生成10个介于100和200之间的整数,查找最大值private sub command1 click()m

怎么用for循环计算数组最大值?代码怎么写?

两个例子希望对你的问题有所帮助(VB):1。随机生成10个介于100和200之间的整数,查找最大值private sub command1 click()max=100 for I=1 to 100 x=int(RND*101 100)print x if x> max then max=x next I print“maximum value”;max end sub 2使用数组函数,然后查找并输出数组中的最大值。Option base 1 private sub command1 click()dim Arrl,Max as integer Arrl=array(12435,76,24,78,54866,43)Max=Arrl(1)for I=1 to 8 if Arrl(I)> then Max=Arrl(I)next I print “maximum”;Max End sub

#Main()

{

int I,N,Max

scanf(%d,&max)

for(I=1I<10i)

{

scanf(%d”,&)

if(n>max)

Max=n

}

printf(%dn”,Max)

C语言:for循环输入10个数,用if求出最大值(不用数组的情况下)?

按排序。

假设数组为n,您可以使用变量t存储最大数,并首先将其分配给n[0]。在for循环中,将数组中的每个元素与T进行比较,如果它大于T,则将它赋给T。