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 71 72 73 74
| #include <cstdlib>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <conio.h>
#include "init.h"
#include "tirage.h"
void tirage (int C[3][12], int T[4][3][12])
{
int m, t, a, b;
mise(m);
struct cartes cartes[10];
for(t=0;t<=5;++t)
{
tirage2(&a, &b, t, C, T, cartes);
}
int O[5];
orga(cartes, O);
}
int mise (int a)
{
cout << "quelle somme voulez vous pariez" << endl;
cin >> a;
return a;
}
void tirage2 (int* pointeurC, int* pointeurN, int t, int C[3][12], int T[4][3][12], struct cartes cartes[10])
{
int x = 0;
const int MAXC = 3;
const int MAXN = 12;
const int MIN = 0;
while(x == 0)
{
srand(time(NULL));
*pointeurC = ((rand() % (MAXC - MIN + 1))+ MIN);
*pointeurN = ((rand() % (MAXN - MIN + 1))+ MIN);
if(C[*pointeurC][*pointeurN] == 1)
{
x = 1;
}
}
C[*pointeurC][*pointeurN] = 0; // On met alors la case de la carte tirée a 0 pour éviter de la repiocher
cartes[t].c = *pointeurC;
cartes[t].n = *pointeurN; // Tirage enregistré dans une structure
cout << " " << *pointeurC;
}
void orga (struct cartes cartes[10], int T[5])
{
int k;
for(int z=0;z<=5;++z)
{
T[z] = cartes[z].n;
}
for (int j=5;j>1;j--)
{
for (int i=1;i<j-1;i++)
{
if (T[i]>T[i+1])
{
k=T[i];
T[i]=T[i+1];
T[i+1]=k;
}
}
}
} |
Partager