Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <stdlib.h>
- #include <time.h>
- using namespace std;
- int rand (void);
- /*
- int Lion(int Tour, bool Dormir){
- int valeur;
- for(int i=1;i<Tour;i+=i/i){
- valeur = rand() % 100;
- if Dormir == True
- }
- }
- */
- bool etat_init(){
- bool etat;
- int baseetat=rand() % 1;
- if(baseetat=1){
- etat=true;
- }else{
- etat=false;
- }
- return etat;
- }
- bool lion_chasser(bool chasser){
- int etat=rand() % 100+1;
- if(etat<=10){
- chasser=true;
- }else{
- chasser=false;
- }
- return chasser;
- }
- bool lion_dormir(bool chasser){
- int etat=rand() % 100+1;
- if(etat<=70){
- chasser=false;
- }else{
- chasser=true;
- }
- return chasser;
- }
- int Lionv(int Tour){
- int nd=0;
- int nc=0;
- int i=0;
- //bool chasser=true;
- bool chasser=etat_init();
- while(i<Tour){
- if (chasser==true){
- nc+=1;
- chasser=lion_chasser(chasser);
- i++;
- //cout<<"ETAT chasser "<<i<<endl;
- }else if(chasser==false){
- nd+=1;
- chasser=lion_dormir(chasser);
- i++;
- //cout<<"etat dormir "<<i<<endl;
- }
- }
- cout<<endl;
- cout<<"nb dormir= "<<nd<<endl;
- cout<<"nb chasser= "<<nc<<endl;
- cout<<"total values= "<<nd+nc<<endl;
- cout<<endl;
- }
- int main()
- {
- int n;
- srand (time(NULL));
- cout<<"saisir nombre values"<<endl;
- //cin>>n;
- n=1000;
- Lionv(n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement