salut,

j'essaie de faire un petit jeu de memory
j'ai juste quelques problemes: parfois il m'indique des touches qui ne sont pas memorisé dans mon tableau chiffre . et lors de l'affichage lorsque j'ai trouve une paire de mots il m'indique toujours les tous indices du tableau cacher ex:

au debut du programme j'ai 1234
5678

apres lorsque je trouve une paire de mots ex kiwi j'ai: 1Kkiwi23kiwi4
5678

et je voudrais bien voir le resultat 1kiwi3kiwi
5678

voici mon programme :
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include <iostream.h>
#include <string.h>
#include <time.h>
#include <stdio.h>
 
 
 
int main(int argc,char** argv)
{
 
	srand((unsigned)time(NULL));
	char mots[8][10];
	strcpy(mots[0],"fraise");
	strcpy(mots[1],"fraise");
	strcpy(mots[2],"pomme");
	strcpy(mots[3],"pomme");
	strcpy(mots[4],"kiwi");
	strcpy(mots[5],"kiwi");
	strcpy(mots[6],"orange");
	strcpy(mots[7],"orange");
 
	char mots_melange[8][10];
	int i,aleatoire;
	int tableau_aleatoire[8];
	int cacher[8];
	int nombre1,nombre2;
	bool game=true;
	bool jeu=true;
	int tour=0;
	int chiffre[8];
 
 
	while(game==true&&tour!=4)
		{
 
		if(jeu==true)
		{
			for (i=0;i<8;i++)
				{    
					 cacher[i]=i+1;
					 cout<<cacher[i];
 
					if (i==3)
					{
						cout<<"\n";
					}
					jeu=false;
				}
 
	for (i=0;i<8;i++)
	{
		tableau_aleatoire[i]=0;
		chiffre[i]=0;
	}
 
	for (i=0;i<8;i++)
	{
	do
	   {
		aleatoire=rand()%8;
		strcpy(mots_melange[i],mots[aleatoire]);
 
	   }while(tableau_aleatoire[aleatoire]==1);
		 tableau_aleatoire[aleatoire]=1;
   }
 
}	
	do{	
	cout<<"tapez un nombre : ";
	cin>>nombre1;
	cout<<"\n"<<mots_melange[nombre1];
	cout<<"\n"<<"tapez un deuxieme nombre : ";
	cin>>nombre2;
	cout<<"\n"<<mots_melange[nombre2];
	if (chiffre[nombre1]==1||chiffre[nombre2]==2)
	{
		cout<<"vous avez deja tapez ses nombre recommencez :\n";
	}
	}while(chiffre[nombre1]==1||chiffre[nombre2]==2);
	cout<<mots_melange[nombre2];cout<<"\n";
	if (strcmp(mots_melange[nombre1],mots_melange[nombre2])==0)
	{
 
		chiffre[nombre1]=1;
		chiffre[nombre2]=2;
		tour++;
		for(i=0;i<8;i++)
		{
 
			if (chiffre[i]==1)
			{
				cout<<mots_melange[i];
 
			}
 
 
 
			if (chiffre[i]==2)
			{
				cout<<mots_melange[i];
 
			}
 
 
			if(chiffre[i]!=1!=chiffre[i]!=2)
			{
				cout<<cacher[i];
 
			}
 
 
 
			if (i==3)
			{
				cout<<"\n";
			}
		}
		cout<<"\n";
	}
 
 
	}
 
 
	return 0;
}
merci !