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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
|
/*
Projet informatique
Labyrinthe du sorcier
*/
#include<stdio.h>
#include<time.h>
/************************************ Programme Principal ******************************/
/****************************************************************************************/
main()
{
/************ declaration des variable et fonction ************/
int * T;
int num,al,al1,al2,G,t1,t2,t3,lev,A,ch,var;
int tab[200];
int tabe[2];
int * T1;
void affichage(int);
void germe(int);
void assigner_fonction(int,int,int,int,int,int);
void fonctiona(int);
void fonctionb(int,int,int,int);
void fonctionc(int,int,int,int *,int,int,int,int,int,int,int);
void alea(int,int,int *,int,int,int,int,int,int,int);
/************ debut du jeu ************/
T=tab;
num=1;
ch=1;
var=1;
printf(" A A\n");
printf(" AAA AAA\n");
printf(" AAAAA AAAAA\n");
printf(" AAAAAAA A_A_A_A_A_A_A_A_A_A_A_A_A_A_A_AAAAAAA\n");
printf(" | [] [] | [] [] [] [] [] | [] [] |\n");
printf(" | | | |\n");
printf(" | | __ | |\n");
printf(" | [] [] | [] [] |_ | [] [] | [] [] |\n");
printf(" |_______|____________|__|_____________|_______|\n");
printf(" / /\n");
printf(" / /\n");
printf(" #/ /#\n");
printf("\t\tBienvenue dans le Manoir \n ");
/************ On commence par la chambre 1 ************/
lev=0;
affichage(var);//affichage de la chambre
germe(G);//creation du germe aleatoire
do
{
printf(" Choisssez votre levier (1,2, ou 3) : ");
scanf("%d",&lev);
}
while ((lev>3) || (lev<0));
/**assigner les fonctions au levier**/
if (lev==1)
{
A=rand()%9000;
if ((A>=0)&&(A<=3000))
al=1;
if ((A>=3000)&&(A<=6000))
al=2;
if ((A>=6000)&&(A<=8999))
al=3;
T[num]=al;
t1=al;
}
if (lev==2)
{
do
{
A=rand()%9000;
if ((A>=0)&&(A<=3000))
al1=1;
if ((A>=3000)&&(A<=6000))
al1=2;
if ((A>=6000)&&(A<=8999))
al1=3;
T[num+50]=al1;
t2=al1;
}
while (t2=!t1);
}
if (lev==3)
{
do
{
A=rand()%9000;
if ((A>=0)&&(A<=3000))
al2=1;
if ((A>=3000)&&(A<=6000))
al2=2;
if ((A>=6000)&&(A<=8999))
al2=3;
T[num+100]=al2;
t3=al2;
}
while ((t3=!t1)&&(t3=!t2));
}
/**associe au choix du levier**/
if ((al==1) || (al1==1) || (al2==1))
{
printf("Vous etes sorti du labyrinthe, vous avez gagne \n");
}
else
if ((al==2) || (al1==2) || (al2==2))
{
fonctionc(al,al1,al2,T,num,lev,A,t1,t2,t3,ch);//appel de la fonction c
}
else
if ((al==3) || (al1==3) || (al2==3))
{
fonctionc(al,al1,al2,T,num,lev,A,t1,t2,t3,ch);//appel de la fonction c
}
}
/* FIN DU PROGRAMME PRINCIPAL */
/************************************PROCEDURES*****************************************/
/**************************************************************************************/
/** affichage de la chambre **/
void affichage (int var)
{
printf(" Vous etes dans la chambre %d\n",var);
printf(" ______________________________________\n");
printf(" | | \n");
printf(" | | \n");
printf(" |____ ____| \n");
printf(" | | | | \n");
printf(" | | ___ ___ ___ | | \n");
printf(" | | |_1_| |_2_| |_3_| | | \n");
printf(" | | | | | | | | | | \n");
printf(" | | || || || || || || | | \n");
printf(" |____|____|___|___|___|___|___|___|____| \n\n");
}
/************ Germe *************/
void germe(int G)
{
G=time(0);
srand(G);
}
/************* Fonction C ******************/
void fonctionc(int al,int al1,int al2,int*T,int num,int lev,int A,int t1,int t2,int t3, int ch)
{
int var,G;
system("clear");
ch++;
printf("\t\t Vous etes projete dans la chambre %d !\n\n",ch);
num=ch;
var=ch;
affichage(var);
germe(G);
alea(lev,A,T,num,al,al1,t2,t3,al2,t1);
}
Donc c'est cette fonction qui me pose problème
/********************* Aleatoire ***********************/
void alea(int lev,int A,int*T,int num,int al,int al1,int t2,int t3,int al2,int t1)
{
if (lev==1)
{
A=rand()%9000;
if ((A>=0)&&(A<=3000))
al=1;
if ((A>=3000)&&(A<=6000))
al=2;
if ((A>=6000)&&(A<=8999))
al=3;
T[num]=al;
t1=al;
}
if (lev==2)
{
do
{
A=rand()%9000;
if ((A>=0)&&(A<=3000))
al1=1;
if ((A>=3000)&&(A<=6000))
al1=2;
if ((A>=6000)&&(A<=8999))
al1=3;
T[num+50]=al1;
t2=al1;
}
while (t2=!t1);
}
if (lev==3)
{
do
{
A=rand()%9000;
if ((A>=0)&&(A<=3000))
al2=1;
if ((A>=3000)&&(A<=6000))
al2=2;
if ((A>=6000)&&(A<=8999))
al2=3;
T[num+100]=al2;
t3=al2;
}
while ((t3=!t1)&&(t3=!t2));
}
} |
Partager