Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <stdlib.h>
  4. #include <time.h>
  5.  
  6. using namespace std;
  7.  
  8. int rand (void);
  9.  
  10. /*
  11. int Lion(int Tour, bool Dormir){
  12. int valeur;
  13. for(int i=1;i<Tour;i+=i/i){
  14. valeur = rand() % 100;
  15. if Dormir == True
  16.  
  17. }
  18.  
  19.  
  20.  
  21. }
  22. */
  23.  
  24.  
  25.  
  26. bool etat_init(){
  27. bool etat;
  28. int baseetat=rand() % 1;
  29. if(baseetat=1){
  30. etat=true;
  31. }else{
  32. etat=false;
  33. }
  34. return etat;
  35. }
  36.  
  37. bool lion_chasser(bool chasser){
  38. int etat=rand() % 100+1;
  39. if(etat<=10){
  40. chasser=true;
  41. }else{
  42. chasser=false;
  43. }
  44. return chasser;
  45. }
  46.  
  47. bool lion_dormir(bool chasser){
  48. int etat=rand() % 100+1;
  49. if(etat<=70){
  50. chasser=false;
  51. }else{
  52. chasser=true;
  53. }
  54. return chasser;
  55. }
  56.  
  57. int Lionv(int Tour){
  58. int nd=0;
  59. int nc=0;
  60. int i=0;
  61. //bool chasser=true;
  62. bool chasser=etat_init();
  63. while(i<Tour){
  64.  
  65. if (chasser==true){
  66. nc+=1;
  67. chasser=lion_chasser(chasser);
  68. i++;
  69. //cout<<"ETAT chasser "<<i<<endl;
  70. }else if(chasser==false){
  71. nd+=1;
  72.  
  73. chasser=lion_dormir(chasser);
  74. i++;
  75. //cout<<"etat dormir "<<i<<endl;
  76. }
  77.  
  78. }
  79. cout<<endl;
  80. cout<<"nb dormir= "<<nd<<endl;
  81. cout<<"nb chasser= "<<nc<<endl;
  82. cout<<"total values= "<<nd+nc<<endl;
  83. cout<<endl;
  84.  
  85.  
  86.  
  87. }
  88.  
  89.  
  90.  
  91. int main()
  92. {
  93. int n;
  94. srand (time(NULL));
  95. cout<<"saisir nombre values"<<endl;
  96. //cin>>n;
  97. n=1000;
  98. Lionv(n);
  99. return 0;
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement