Advertisement
kajs54

ex3 s10

May 4th, 2022
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. # ex3
  2. from numpy import *
  3. t=array([str]*100)
  4. t1=array([str()]*100)
  5. def saisie():
  6. while True:
  7. n=int(input("n="))
  8. if 2<n<20: break
  9. return n
  10. def remplir1(n):
  11. for i in range(n):
  12. while True:
  13. t[i]=input("t["+str(i)+"]:")
  14. if len(t[i])>0: break
  15. return t,n
  16. def remplir2(m):
  17. for i in range(m):
  18. y=i+97
  19. t1[i]=chr(y)
  20. return t1,m
  21. def commun(t,t1,n,m):
  22. ch=""
  23. for i in range(m):
  24. s=0
  25. for j in range(n):
  26. if t[j].find(t1[i])!=-1 :
  27. s=s+1
  28. if s==n:
  29. ch=t1[i]+","+ch
  30. return ch[:-1]
  31. def afficher(t1,m):
  32. for i in range(m):
  33. print(t1[i],end="/")
  34. print()
  35. m=26
  36. n=saisie()
  37. t,n=remplir1(n)
  38. t1,m=remplir2(m)
  39. afficher(t1,m)
  40. print("les caractéres communs sont:", commun(t,t1,n,m))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement