-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython-code-corrigé.py
More file actions
36 lines (30 loc) · 827 Bytes
/
python-code-corrigé.py
File metadata and controls
36 lines (30 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from numpy import array
# Fonction pour saisir et valider la taille du tableau
def sasir():
n=int(input("Donner le taille du tableau=:"))
while not (3 <=n<= 5):
n=int(input("Donner taille du tableau=:"))
return n
# Fonction pour remplir le tableau avec des valeurs positif est unique
def remplir(t, n):
for i in range(n):
t[i] = int(input("t[" + str(i) + "] = "))
while not (t[i] > 0 and unique(t,i) ):
t[i] = int(input("t[" + str(i) + "] = "))
def unique(t,x):
i=0
test=False
while test==False and i<x:
if t[i]==t[x]:
test=True
else:
i=i+1
return not(test)
def affichage(t,n):
for i in range(n):
print(t[i],end="|")
# Programme Principal
n=sasir()
t=array([int()]*n)
remplir(t,n)
affichage(t,n)