Télécharger au format docx, pdf ou txt
Télécharger au format docx, pdf ou txt
Vous êtes sur la page 1sur 1

Tri insertion : tableau d’enregistrements 3 Sc_inf

Activité : def trie(t,n) :


for i in range(1,n):
Ecrire un programme qui permet de remplir un tableau T par n if t[i]["moy"]>t[i-1]["moy"]:
(2<=n<=30) enregistrements eleve( nom : chaine, moy : réel) aux ={}
puis l’afficher aux=t[i]
p=i
while (p >0) and (aux["moy"]>t[p-1]["moy"]):
from numpy import * t[p]=t[p-1]
eleve = dict (nom = str, moy = float) p=p-1
t=array([eleve]*30) t[p]=aux

# module saisi de n # module afficher : afficher un tableau d’enregistrements


def saisi (): def afficher(t,n) :
n = int (input(" N = ")) for i in range (n):
while not(2<=n<=30): print("nom élève n°", i,": ",t[i]["nom"])
n = int (input(" N = ")) print("moyenne élève n°", i," :",t[i]["moy"])
return n
#Programme Principal
# module remplir t n=saisi()
def remplir (t,n): remplir(t,n)
for i in range (n): print ("avant : ")
t[i]={} afficher(t,n)
t[i]["nom"]=input("nom élève n° "+str(i)+": ") trie(t,n)
t[i]["moy"]=int(input("moyenne élève n° "+str(i)+": ")) print("apres : ")
afficher(t,n)

# Module trier le tableau : tri par insertion d’un tableau d’enregistrements

Vous aimerez peut-être aussi