Home > other >  Python beginners hope bosses wrong answers to the following program? (wrong)
Python beginners hope bosses wrong answers to the following program? (wrong)

Time:09-20

Input array, the biggest and the first element exchange, minimum exchange, with the last element of the array output

Application:
Def inp (Numbers) :
For I in range (10) :
Numbers. Append (int (input (' input a number:)))

Def max_min (array) :
Max=0
Min=9
For I in range (1, len (array) - 1) :
If an array [I] & gt; Array (Max) : Max=I
Elif array [I] K=Max
L=min
Array [0], array [k]=array [k], array [0]
Array [9], array [l]=array [l], array [9]

Def outp (Numbers) :
For I in range (len (Numbers) :
Print (Numbers [I])

If __name__=="__main__ ':
Array=[]
Inp (array)
Max_min (array)
Outp (array)

CodePudding user response:

 
Def inp (Numbers) :
For I in range (10) :
Numbers. Append (int (input (' input a number:)))

Def max_min (array) :
K=Max=0
L=min=9
For I in range (1, len (array) - 1) :
If an array [I] & gt; Array (Max) : Max=I
If an array [I] K=Max
L=min
Array [0], array [k]=array [k], array [0]
Array [9], array [l]=array [l], array [9]

Def outp (Numbers) :
For I in range (len (Numbers) :
Print (Numbers [I])

If __name__=="__main__ ':
Array=[]
Inp (array)
Max_min (array)
Outp (array)
  • Related