Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
6 views1 page

EeeTriInsertion Py

Uploaded by

boukthir03
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)
6 views1 page

EeeTriInsertion Py

Uploaded by

boukthir03
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/ 1

1 def Lecture() :

2 N = 0
3 while ( not (1<N<20) ) :
4 N = int(input("saisir n "))
5 return N
6
7 from numpy import array
8 TA = array ([int( )] * 20)
9
10 def Remplir (N , TA) :
11 for i in range ( 1 , N+1 , 1 ) :
12 TA[i] = int (input ("TA [" + str(i) + " ] " ))
13
14 def Affiche (N , TA) :
15 for i in range ( 1 , N+1 , 1 ) :
16 print(TA[i], end="#")
17 print()
18
19
20 def Tri_insertion1 (N , TA ):
21 for j in range (2 , N+1 , 1 ) :
22 tmp=TA[j]
23 i = j
24 while(i > 1) and (TA[i-1]>tmp ) :
25 TA[i]=TA[i-1]
26 i = i-1
27 TA[i] = tmp
28
29 def Tri_insertion0 (N , TA ):
30 for j in range (1 , N , 1 ) :
31 tmp=TA[j]
32 i = j
33 while (i > 0) and (TA[i-1]>tmp ) :
34 TA[i]=TA[i-1]
35 i = i-1
36 TA[i] = tmp
37
38
39 #P.P.
40 N =Lecture( )
41 print(N)
42
43 Remplir (N , TA)
44 print(TA)
45 print("Tableau non ordonné")
46 Affiche (N , TA)
47 Tri_insertion0 (N , TA )
48 print("Tableau ordonné")
49 Affiche (N , TA)

You might also like