0% found this document useful (0 votes)
4 views2 pages

Correction Tri

Uploaded by

MokdedJbali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Correction Tri

Uploaded by

MokdedJbali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Matière : informatique Niveau :4Math+4Sc.

Ex
Enseignant : J.Mokded
Importation des bibliothèques
Application N°1:
from string import*

from math import*


pm=j
from numpy import*
if pm!= i :
#Défintion de la procédure saisie
aux=m[i]
def saisie():
m[i]=m[pm]
global n
m[pm]=aux
n=0
temp=s[i]
while not (2<=n<=100):
s[i]=s[pm]
n=int(input("donner n"))
s[pm]=temp
#Défintion de la procédure remplir
#Défintion de la procédure affiche
def remplir(m,s,n):
def affiche (m,n):
for i in range (n):
p=round(n*(25/100))
m[i]=" "
for i in range (0,p):
while m[i].isnumeric()==False or len(m[i])!=8 :
print(m[i])
m[i]=input("matricule"+str(i+1))
#corps du programme principal
s[i]=0
saisie()
while s[i]<20 or s[i]>120:
m=array([str]*n)
s[i] =int(input("score"+str(i+1)))
s=array([int()]*n)
#Défintion de la procédure Triselection
remplir(m,s,n)
def triselection():
print("Les employés admis sont")
for i in range (0,n-1):
affiche(m,n)
pm=i

for j in range (i+1,n):

if s[j]>s[pm]:

1
Matière : informatique Niveau :4Math+4Sc.Ex
Enseignant : J.Mokded

Application N°2 :

from numpy import *


def verif(ch):
ok = True
i=0
ch = ch.upper()
while ok and i < len(ch): def saisie():
if ch[i] >= "A" and ch[i] <= "Z" or ch[i] == " ": global N
i +=1 N=0
else : while N < 5 or N > 100:
ok = False N = int(input("donner N " ))
return ok def affiche(T,S):
def remplir1(T): d=1
for i in range(5): print(d, ":",T[0] , end = " ")
T[i] = "!" for i in range(1,5):
while verif(T[i])==False: if S[i]== S[i-1]:
T[i] = input("donner la chanson "+str(i+1)) print(",", T[i] , end= " ")
def remplir2(S,N): else:
for i in range(1 , N+1): d = d+1
choix = -2 print()
while choix < 1 or choix > 5: print(d,":", T[i] , end = " ")
choix = int(input("donner votre choix "))
S[choix-1]=S[choix-1]+3 T = array([str] * 5)
def tri(T,S): S = array([int()] * 5)
ok = True remplir1(T)
while ok: saisie()
ok = False remplir2(S,N)
for i in range(4): tri(T,S)
if S[i] < S[i+1]: affiche(T,S)
aux = T[i]
T[i] = T[i+1]
T[i+1] = aux
temp = S[i]
S[i] = S[i+1]
S[i+1] = temp
ok = True

You might also like