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
|
#include<iostream>
#include<time.h>
#include<fstream>
using namespace std;
// Générateur de cartes
short genererCarte( char cartes[], short valeurs[], char &carte, short &points )
{
int i =0;
for (int i=0; i<13; i++)
{
rand(); }
carte = cartes[i] ;
points = valeurs[i] ;
return rand() ;
}
int main()
{
char Cartes[13] = { 'A', '2', '3', '4', '5', '6', '7', '8', '9', 'X', 'V', 'D', 'R' } ;
short Valeurs[13] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10 } ;
// Rendre le comportement du programme un peu plus aléatoire
srand( unsigned int (time( NULL ) ) ) ;
short mesPoints ;
char maCarte ;
short monIndice ;
monIndice = genererCarte( Cartes, Valeurs, maCarte, mesPoints ) ;
//Generer 100 fois
for (int i=0; i<100; i++)
{
cout << "Les resultats sont :" << endl ;
cout << " Carte = " << maCarte << " Points = " << mesPoints << endl ;
}
//fichier carte.text
ifstream fichier("carte.txt", ios::in); // on ouvre
if(fichier)
{
fichier.close();//on ferme
}
else
cerr << "Impossible d'ouvrir le fichier !" << endl;
system("pause");
return 0;} |
Partager