Bonjour, je m'essaye au C++ et j'ai voulu faire un mini-jeux avec mes connaissances. Mais je ne comprend pas où sa plante.
Ce jeux est celui du pierre feuille ciseaux, faites un petit test pour voir comment il nemarche pas ^^.
Merci de m'aider dans un premier temps à le faire marcher et dans un deuxieme temps à simplifier mon code, des if tout le long je pense qu'il y a mieux mais je ne connais pas.
Merci d'avance.


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
 
int main(int nNumberofArgs, char* pszArgs[])
{
    cout << "Voici le jeux du pierre-feuille-ciseaux.\n 0 = pierre\n 1=feuille\n 2=ciseaux\n 3 pour quitter" << endl;
 
    int chxUt, randComp, TUt, TComp;
 
    re:
        randComp = rand() % 3;
 
        cin >> chxUt;
        if (chxUt > 3)
        {
                  cout << "Entrez un nombre compris entre 0 et 3" << endl;
                  goto re;
        }
 
        if (chxUt = 0)
        {
              if (randComp = 1)
              {
                           cout << "pierre - pierre" << endl;
                           cout << "   EGALITE" << endl;
              }
 
              if (randComp = 2)
              {
                           cout << "pierre - feuille" << endl;
                           cout << "   PERDU" << endl;
                           TComp++;
              }
 
              if (randComp = 3)
              {
                           cout << "pierre - ciseaux" << endl;
                           cout << "   GAGNE" << endl;
                           TUt++;
              }
 
              goto re;
        }
 
        if (chxUt = 1)
        {
              if (randComp = 1)
              {
                           cout << "feuille - pierre" << endl;
                           cout << "   GAGNE" << endl;
                           TUt++;
              }
 
              if (randComp = 2)
              {
                           cout << "feuille - feuille" << endl;
                           cout << "   EGALITE" << endl;
              }
 
              if (randComp = 3)
              {
                           cout << "feuille - ciseaux" << endl;
                           cout << "   PERDU" << endl;
                           TComp++;
              }
 
              goto re;
        }
 
        if (chxUt = 2)
        {
              if (randComp = 1)
              {
                           cout << "ciseaux - pierre" << endl;
                           cout << "   PERDU" << endl;
                           TComp++;
              }
 
              if (randComp = 2)
              {
                           cout << "ciseaux - feuille" << endl;
                           cout << "   GAGNE" << endl;
                           TUt++;
              }
 
              if (randComp = 3)
              {
                           cout << "ciseaux - ciseaux" << endl;
                           cout << "   EGALITE" << endl;
              }
 
              goto re;
        }
 
    if (chxUt = 3)
    {
              cout << "Fin de la partie.\n Score:\n Utilisateur : " << TUt << "\n Ordinateur : " << TComp << endl;
              goto fin;
    }
    fin:
    system("PAUSE");
    return 0; 
}