def find_maxinum_value(A):
maxNumber = 0;
count = 0;
while(count<len(A)):
if(A[count] > maxNumber):
maxNumber = A[count]
count = 1+count
return maxNumber
def find_first_max_value(A):
maxN = find_maxinum_value(A)
count = 0;
while(count<len(A)):
if(A[count] == maxN):
index = count
count = len(A)
count = 1+count
return index
def setup():
A = [-5,5,10,20,30,40,-50,-60,-80,-100,40]
print (find_maxinum_value(A),"is the maxinum value")
print (find_first_max_value(A)," is the first index in maxvalue")
setup()
ผลลัพธ์
40 is the maxinum value 5 is the first index in maxvalue
def find_maxinum_value(A):
maxNumber = 0;
count = 0;
while(count<len(A)):
if(A[count] > maxNumber):
maxNumber = A[count]
count = 1+count
return maxNumber
def find_first_max_value(A):
maxN = find_maxinum_value(A)
count = 0;
while(count<len(A)):
if(A[count] == maxN):
index = count
count = 1+count
return index
def setup():
A = [-5,5,10,20,30,40,-50,-60,-80,-100,40]
print (find_maxinum_value(A),"is the maxinum value")
print (find_first_max_value(A)," is the first index in maxvalue")
setup()
ผลลัพธ์
40 is the maxinum value 10 is the last index in maxvalue
ไม่มีความคิดเห็น:
แสดงความคิดเห็น