Vector Duh
This commit is contained in:
parent
8d88e8ba26
commit
196c50dde2
@ -1,5 +1,5 @@
|
||||
# python_man
|
||||
simple lib, clear, pause, see if pair, order array
|
||||
simple lib, clear, pause, see if pair, order Vector
|
||||
|
||||
man.clear()
|
||||
|
||||
@ -7,13 +7,13 @@ man.paused()
|
||||
|
||||
pair = man.pair(number) #return boolean
|
||||
|
||||
order = man.orderArray([num1,num2,num3]) # return array
|
||||
order = man.orderVector([num1,num2,num3]) # return Vector
|
||||
|
||||
reverse = man.reverseArray([num1,num2,num3]) # return array
|
||||
reverse = man.reverseVector([num1,num2,num3]) # return Vector
|
||||
|
||||
# Install
|
||||
|
||||
1. Download man.py - here https://github.com/Can202/python_man/releases/download/v1.0/man.py
|
||||
1. Download man.py - here https://github.com/Can202/python_man/releases/download/v1.1/man.py
|
||||
|
||||
2. Put the man.py next to your code
|
||||
|
||||
|
30
man.py
30
man.py
@ -10,9 +10,9 @@ def pair(num):
|
||||
result = False
|
||||
return result
|
||||
|
||||
#Use man.orderArray([0,2,3,20,5,2,50]), the result is order
|
||||
def orderArray(array):
|
||||
numberis = len(array)
|
||||
#Use man.orderVector([0,2,3,20,5,2,50]), the result is order
|
||||
def orderVector(vector):
|
||||
numberis = len(vector)
|
||||
torepeat = False
|
||||
repeathat = True
|
||||
|
||||
@ -20,29 +20,29 @@ def orderArray(array):
|
||||
i = 0
|
||||
for i in range(numberis):
|
||||
if i != 0:
|
||||
if array[i] < array[i-1]:
|
||||
if vector[i] < vector[i-1]:
|
||||
torepeat = True
|
||||
m = array[i-1]
|
||||
array[i-1] = array[i]
|
||||
array[i] = m
|
||||
m = vector[i-1]
|
||||
vector[i-1] = vector[i]
|
||||
vector[i] = m
|
||||
if torepeat == True:
|
||||
torepeat = False
|
||||
repeathat = True
|
||||
else:
|
||||
repeathat = False
|
||||
|
||||
return array
|
||||
return vector
|
||||
|
||||
#Use man.reverseArray([0,2,5,1,5,34]), the result is reverse
|
||||
def reverseArray(array):
|
||||
numberis = len(array)
|
||||
#Use man.reverseVector([0,2,5,1,5,34]), the result is reverse
|
||||
def reverseVector(vector):
|
||||
numberis = len(vector)
|
||||
numberis2 = numberis // 2
|
||||
for i in range(numberis2):
|
||||
y = numberis - i - 1
|
||||
m = array[i]
|
||||
array[i] = array[y]
|
||||
array[y] = m
|
||||
return array
|
||||
m = vector[i]
|
||||
vector[i] = vector[y]
|
||||
vector[y] = m
|
||||
return vector
|
||||
|
||||
|
||||
#Use man.paused()
|
||||
|
Loading…
x
Reference in New Issue
Block a user