1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| #include<iostream>
using namespace std;
int maxi(int t1[]){
int k=t1[0];
int i, nbreche;
for(i=1;i<nbreche;i++ ){
if (t1[i]>k){
k=t1[i];
i=i+1;
}
}
return k;
}
void affichage(int t1[],int nbreche,int d){
int l=1;
cout << " D";
for (int j=1; j<d; j++) // boucle affichage 1ère ligne
cout << " ";
cout << "A" << endl;
cout << " ";
for (int j=1; j<d+4; j++) // boucle affichage 2ème ligne
cout << "-";
cout << endl;
while (l<=nbreche){ // boucle affichage des chevaux
cout << l << " : ";
int r=0;
while (r<t1[l-1]){
cout<<"*";
r=r+1;
}
cout<<"C";
int s=1;
while (s<d-t1[l])
cout<<" ";
cout<<"|"<<endl;
l=l+1;
}
cout << " ";
for (int i=1; i<d+4; i++) // boucle affichage dernière ligne ligne
cout << "-";
cout << endl;
}
int main(void){
int nbreche,d, k=0, ale;
int t1[nbreche];
char c;
cout << "Combien y a t'il de participant au tiercé quarté quinté+ d'aujourd'hui ?" << endl;
cin >> nbreche;
while (nbreche>=10){
cout << "entrer un nombre inférieur a 10" << endl;
cin >> nbreche;}
cout << "Quelle est la distance du parcours ?" << endl;
cin >> d;
while (k<nbreche)
t1[k]=0;
int m=maxi(t1);
cin>>m;
while (m<d){
cin>>c;
srand(time(NULL));
ale=(rand() %nbreche)+1;
t1[ale]=t1[ale]+1;
affichage(t1,nbreche,d);
}
} |
Partager