2018-11-03 20:08:13 +00:00
|
|
|
def absMax(x):
|
|
|
|
"""
|
2018-12-04 17:18:32 +00:00
|
|
|
#>>>absMax([0,5,1,11])
|
2018-11-03 20:08:13 +00:00
|
|
|
11
|
|
|
|
>>absMax([3,-10,-2])
|
|
|
|
-10
|
|
|
|
"""
|
2018-12-04 17:18:32 +00:00
|
|
|
j =x[0]
|
2018-11-03 20:08:13 +00:00
|
|
|
for i in x:
|
2019-02-15 16:01:10 +00:00
|
|
|
if abs(i) > abs(j):
|
2018-11-03 20:08:13 +00:00
|
|
|
j = i
|
|
|
|
return j
|
2019-02-15 16:01:10 +00:00
|
|
|
|
2018-11-03 20:08:13 +00:00
|
|
|
|
|
|
|
def main():
|
2019-02-15 16:01:10 +00:00
|
|
|
a = [1,2,-11]
|
|
|
|
print(absMax(a)) # = -11
|
|
|
|
|
2018-11-03 20:08:13 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|
2018-12-04 17:18:32 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
print abs Max
|
2018-12-04 17:32:53 +00:00
|
|
|
"""
|