Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. #include "TableauDynamique.h"
  4. #include "ElementTD.h"
  5.  
  6. using namespace std;
  7.  
  8. void indiceFrequence(ElementTD freq, ElementTD indMax, TableauDynamique &tab)
  9. {
  10. ElementTD i = freq;
  11.  
  12. while(i <= indMax + 1)
  13. {
  14. tab.ajouterElement(i - 1);
  15. i += freq;
  16. }
  17. }
  18.  
  19. void cribleChanceux(TableauDynamique &tab)
  20. {
  21. int indice = 1;
  22. unsigned int freq = tab.valeurIemeElement(indice);
  23.  
  24. while(freq < tab.taille_utilisee)
  25. {
  26. for(unsigned int i = freq; i < tab.taille_utilisee; i = i + freq)
  27. {
  28. tab.supprimerElement(i-1);
  29. i--;
  30. }
  31.  
  32. indice++;
  33. freq = tab.valeurIemeElement(indice);
  34. }
  35. }
  36.  
  37. int main()
  38. {
  39. TableauDynamique tab;
  40.  
  41. indiceFrequence(2, 100, tab);
  42. tab.afficher();
  43.  
  44. cribleChanceux(tab);
  45. tab.afficher();
  46.  
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement