begin process at 2012 05 27 17:44:47
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Jeux

 > UN PETIT PENDU EN C

UN PETIT PENDU EN C


 Information sur la source

Note :
4 / 10 - par 2 personnes
4,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Jeux Niveau :Débutant Date de création :09/11/2003 Date de mise à jour :09/11/2003 16:45:17 Vu / téléchargé :9 829 / 338

Auteur : tof2503

Ecrire un message privé
Commentaire sur cette source (2)
Ajouter un commentaire et/ou une note

 Description

Un petit pendu pour s'amuser a deux

Source

  • /* jeux de pendu
  • */
  • #include<conio.h>
  • #include<stdio.h>
  • #include<dos.h>
  • #define TAILLE_MAX 25
  • /*Declaration des fonctions*/
  • char traduction_maj_minus(char);
  • void initialisation(char *, char *);
  • int detection(char,char *,char *);
  • int mot_trouve(char *);
  • void dessin(int);
  • /*Fonction Principal*/
  • void main()
  • {
  • char mot_trouver[TAILLE_MAX];
  • char mot_trou[TAILLE_MAX];
  • int cpt2,cpt,m,n,q,x,i=0;
  • char *ptr_trouver;
  • char *ptr_trou;
  • ptr_trouver=mot_trouver;
  • ptr_trou=mot_trou;
  • char lettre_trouve[TAILLE_MAX];
  • char c;
  • clrscr();
  • for(x=0;x<TAILLE_MAX;x++){
  • lettre_trouve[x]='\0';
  • }
  • for(x=0;x<26;x++){
  • textcolor(x);
  • clrscr();
  • gotoxy(x,1);
  • cputs("*****************************\n");
  • gotoxy(x,2);
  • cputs("* BIENVENUE AU PENDU *\n");
  • gotoxy(x,3);
  • cputs("*****************************");
  • delay(100);
  • }
  • gotoxy(34,5);
  • puts("By Miguel");
  • gotoxy(33,6);
  • puts("Version 1.2");
  • gotoxy(33,23);
  • textcolor(9+128);
  • cprintf("Chargement:");
  • for(x=1;x<80;x++){
  • gotoxy(x,24);
  • printf("%c",219);
  • delay(50);
  • }
  • textcolor(7);
  • while(q!=2){
  • clrscr();
  • cpt2=0,cpt=0,m=1,n=1,q;
  • puts("Bonjour joueur 1");
  • printf("Entrer votre mot (attention les espaces ne marchent pas) :\n");
  • scanf("%s",&mot_trouver);
  • fflush(stdin);
  • /*conversion majuscule -> minuscule*/
  • while(mot_trouver[cpt]!='\0'){
  • mot_trouver[cpt]=traduction_maj_minus(mot_trouver[cpt]);
  • cpt=cpt+1;
  • }
  • initialisation(ptr_trouver,ptr_trou);
  • fflush(stdin);
  • /*entrer des essais*/
  • while(m!=8){
  • clrscr();
  • gotoxy(1,10);
  • puts("lettre taper : ");
  • printf("%s\n",lettre_trouve);
  • dessin(m); /*fonction du dessin du pendu*/
  • gotoxy(1,1);
  • printf("A votre tour joueur 2 essayer de trouver le mot\n");
  • printf("vous avez 7 essais il vous reste %d chance(s)\n",(8-m));
  • printf("mot a trouver : %s\n",mot_trou);
  • printf("entrer un caractere : ");
  • scanf("%c",&c);
  • lettre_trouve[i]=c;
  • i=i+1;
  • fflush(stdin);
  • cpt2=detection(c,ptr_trouver,ptr_trou);
  • if(cpt2!=0){
  • textcolor(9);
  • m=m;
  • }
  • else{
  • textcolor(4);
  • m=m+1;
  • }
  • n=mot_trouve(ptr_trou);
  • if(n==0){
  • m=8;
  • textcolor(9);
  • cprintf("BRAVO!!! vous avez gagner le mot ete : %s",mot_trouver);
  • getch();
  • clrscr();
  • printf("Voulez vous retentez votre chance??\n1 : oui\n2 : non ");
  • }
  • if((m>7)&&(n!=0)){
  • textcolor(4);
  • cprintf("dommage, vous avez perdu le mot ete : %s",mot_trouver);
  • dessin(m);
  • getch();
  • clrscr();
  • printf("Voulez voir si vous arrivez a trouver un autre mot??\n1 : oui\n2 : non ");
  • }
  • }
  • scanf("%d",&q);
  • }
  • }
  • /*Fonction traduction majuscule -> minuscule*/
  • char traduction_maj_minus(char c)
  • {
  • if((c>=65)&&(c<=90)){
  • c=c+32;
  • }
  • return c;
  • }
  • /*Fonction initialisation*/
  • void initialisation(char *(chaine1),char *(chaine2))
  • {
  • int cpt=0;
  • while(*(chaine1+cpt)!='\0'){
  • *(chaine2+cpt)='-';
  • cpt=cpt+1;
  • }
  • cpt=cpt+1;
  • *(chaine2+cpt)='\0';
  • }
  • /*Fonction test des lettres*/
  • int detection(char c,char *(chaine1),char *(chaine2))
  • {
  • int cpt=0,cpt2=0;
  • while(*(chaine1+cpt)!='\0'){
  • if(*(chaine1+cpt)==c){
  • *(chaine2+cpt)=c;
  • cpt2=cpt2+1;
  • }
  • cpt=cpt+1;
  • }
  • return cpt2;
  • }
  • /*Fonction comptage de "-" restant*/
  • int mot_trouve(char *(chaine1))
  • {
  • int cpt=0,cpt2=0;
  • while(*(chaine1+cpt)!='\0'){
  • cpt2=cpt2+1;
  • cpt=cpt+1;
  • }
  • cpt=0;
  • while(*(chaine1+cpt)!='\0'){
  • if(*(chaine1+cpt)!='-'){;
  • cpt2=cpt2-1;
  • }
  • cpt=cpt+1;
  • }
  • return cpt2;
  • }
  • /*fonction dessin du pendu*/
  • void dessin(int m){
  • int i=92;
  • switch(m){
  • case 2 :gotoxy(29,24);
  • puts("/");
  • gotoxy(31,23);
  • puts("/");
  • gotoxy(32,23);
  • printf("%c",i);
  • gotoxy(34,24);
  • printf("%c",i);
  • break;
  • case 3 :gotoxy(29,24);
  • puts("/");
  • gotoxy(31,23);
  • puts("/");
  • gotoxy(32,23);
  • printf("%c",i);
  • gotoxy(34,24);
  • printf("%c",i);
  • gotoxy(31,22);
  • puts("|");
  • gotoxy(31,21);
  • puts("|");
  • gotoxy(31,20);
  • puts("|");
  • gotoxy(31,19);
  • puts("|");
  • gotoxy(31,18);
  • puts("|");
  • break;
  • case 4 :gotoxy(29,24);
  • puts("/");
  • gotoxy(31,23);
  • puts("/");
  • gotoxy(32,23);
  • printf("%c",i);
  • gotoxy(34,24);
  • printf("%c",i);
  • gotoxy(31,22);
  • puts("|");
  • gotoxy(31,21);
  • puts("|");
  • gotoxy(31,20);
  • puts("|");
  • gotoxy(31,19);
  • puts("|");
  • gotoxy(31,18);
  • puts("|");
  • gotoxy(32,17);
  • puts("________");
  • break;
  • case 5 :gotoxy(29,24);
  • puts("/");
  • gotoxy(31,23);
  • puts("/");
  • gotoxy(32,23);
  • printf("%c",i);
  • gotoxy(34,24);
  • printf("%c",i);
  • gotoxy(31,22);
  • puts("|");
  • gotoxy(31,21);
  • puts("|");
  • gotoxy(31,20);
  • puts("|");
  • gotoxy(31,19);
  • puts("|");
  • gotoxy(31,18);
  • puts("|");
  • gotoxy(32,17);
  • puts("________");
  • gotoxy(39,18);
  • puts("|");
  • break;
  • case 6 :gotoxy(29,24);
  • puts("/");
  • gotoxy(31,23);
  • puts("/");
  • gotoxy(32,23);
  • printf("%c",i);
  • gotoxy(34,24);
  • printf("%c",i);
  • gotoxy(31,22);
  • puts("|");
  • gotoxy(31,21);
  • puts("|");
  • gotoxy(31,20);
  • puts("|");
  • gotoxy(31,19);
  • puts("|");
  • gotoxy(31,18);
  • puts("|");
  • gotoxy(32,17);
  • puts("________");
  • gotoxy(39,18);
  • puts("|");
  • gotoxy(39,19);
  • puts("O");
  • break;
  • case 7 :gotoxy(29,24);
  • puts("/");
  • gotoxy(31,23);
  • puts("/");
  • gotoxy(32,23);
  • printf("%c",i);
  • gotoxy(34,24);
  • printf("%c",i);
  • gotoxy(31,22);
  • puts("|");
  • gotoxy(31,21);
  • puts("|");
  • gotoxy(31,20);
  • puts("|");
  • gotoxy(31,19);
  • puts("|");
  • gotoxy(31,18);
  • puts("|");
  • gotoxy(32,17);
  • puts("________");
  • gotoxy(39,18);
  • puts("|");
  • gotoxy(39,19);
  • puts("O");
  • gotoxy(39,20);
  • puts("|");
  • gotoxy(39,21);
  • puts("|");
  • break;
  • case 8 :gotoxy(29,24);
  • puts("/");
  • gotoxy(31,23);
  • puts("/");
  • gotoxy(32,23);
  • printf("%c",i);
  • gotoxy(34,24);
  • printf("%c",i);
  • gotoxy(31,22);
  • puts("|");
  • gotoxy(31,21);
  • puts("|");
  • gotoxy(31,20);
  • puts("|");
  • gotoxy(31,19);
  • puts("|");
  • gotoxy(31,18);
  • puts("|");
  • gotoxy(32,17);
  • puts("________");
  • gotoxy(39,18);
  • puts("|");
  • gotoxy(39,19);
  • puts("O");
  • gotoxy(39,20);
  • puts("|");
  • gotoxy(39,21);
  • puts("|");
  • gotoxy(38,20);
  • puts("/");
  • gotoxy(38,22);
  • puts("/");
  • gotoxy(40,20);
  • printf("%c",i);
  • gotoxy(40,22);
  • printf("%c",i);
  • break;
  • }
  • }
/*								jeux de pendu





*/

#include<conio.h>
#include<stdio.h>
#include<dos.h>
#define TAILLE_MAX 25

/*Declaration des fonctions*/
char traduction_maj_minus(char);
void initialisation(char *, char *);
int detection(char,char *,char *);
int mot_trouve(char *);
void dessin(int);


/*Fonction Principal*/
void main()
{
char mot_trouver[TAILLE_MAX];
char mot_trou[TAILLE_MAX];
int cpt2,cpt,m,n,q,x,i=0;
char *ptr_trouver;
char *ptr_trou;
ptr_trouver=mot_trouver;
ptr_trou=mot_trou;
char lettre_trouve[TAILLE_MAX];
char c;

clrscr();
for(x=0;x<TAILLE_MAX;x++){
	lettre_trouve[x]='\0';
}

for(x=0;x<26;x++){
	textcolor(x);
	clrscr();
	gotoxy(x,1);
	cputs("*****************************\n");
	gotoxy(x,2);
	cputs("*    BIENVENUE AU PENDU     *\n");
	gotoxy(x,3);
	cputs("*****************************");
	delay(100);
}
gotoxy(34,5);
puts("By Miguel");
gotoxy(33,6);
puts("Version 1.2");
gotoxy(33,23);
textcolor(9+128);
cprintf("Chargement:");
for(x=1;x<80;x++){
	gotoxy(x,24);
	printf("%c",219);
	delay(50);
}

textcolor(7);
while(q!=2){
	clrscr();
	cpt2=0,cpt=0,m=1,n=1,q;
	puts("Bonjour joueur 1");
	printf("Entrer votre mot (attention les espaces ne marchent pas) :\n");
	scanf("%s",&mot_trouver);
	fflush(stdin);
	/*conversion majuscule -> minuscule*/
	while(mot_trouver[cpt]!='\0'){
		mot_trouver[cpt]=traduction_maj_minus(mot_trouver[cpt]);
		cpt=cpt+1;
	}
	initialisation(ptr_trouver,ptr_trou);
	fflush(stdin);
	/*entrer des essais*/
	while(m!=8){
		clrscr();

		gotoxy(1,10);
		puts("lettre taper : ");
		printf("%s\n",lettre_trouve);
		dessin(m); /*fonction du dessin du pendu*/
		gotoxy(1,1);
		printf("A votre tour joueur 2 essayer de trouver le mot\n");
		printf("vous avez 7 essais il vous reste %d chance(s)\n",(8-m));
		printf("mot a trouver : %s\n",mot_trou);
		printf("entrer un caractere : ");
		scanf("%c",&c);
		lettre_trouve[i]=c;
		i=i+1;
		fflush(stdin);
		cpt2=detection(c,ptr_trouver,ptr_trou);
		if(cpt2!=0){
			textcolor(9);
			m=m;
		}
	else{
		textcolor(4);
		m=m+1;
	}
	n=mot_trouve(ptr_trou);
	if(n==0){
		m=8;
		textcolor(9);
		cprintf("BRAVO!!! vous avez gagner le mot ete : %s",mot_trouver);
		getch();
		clrscr();
		printf("Voulez vous retentez votre chance??\n1 : oui\n2 : non ");
	}
	if((m>7)&&(n!=0)){
		textcolor(4);
		cprintf("dommage, vous avez perdu le mot ete : %s",mot_trouver);
		dessin(m);
		getch();
		clrscr();
		printf("Voulez voir si vous arrivez a trouver un autre mot??\n1 : oui\n2 : non ");
	}
}
scanf("%d",&q);
}
}

/*Fonction traduction majuscule -> minuscule*/
char traduction_maj_minus(char c)
{
if((c>=65)&&(c<=90)){
	c=c+32;
}
return c;
}


/*Fonction initialisation*/
void initialisation(char *(chaine1),char *(chaine2))
{
int cpt=0;

while(*(chaine1+cpt)!='\0'){
	*(chaine2+cpt)='-';
	cpt=cpt+1;
}
cpt=cpt+1;
*(chaine2+cpt)='\0';
}



/*Fonction test des lettres*/
int detection(char c,char *(chaine1),char *(chaine2))
{
int cpt=0,cpt2=0;

while(*(chaine1+cpt)!='\0'){
	if(*(chaine1+cpt)==c){
	*(chaine2+cpt)=c;
	cpt2=cpt2+1;
   }
cpt=cpt+1;
}
return cpt2;
}



/*Fonction comptage de "-" restant*/
int mot_trouve(char *(chaine1))
{
int cpt=0,cpt2=0;
while(*(chaine1+cpt)!='\0'){
	cpt2=cpt2+1;
	cpt=cpt+1;
}
cpt=0;
while(*(chaine1+cpt)!='\0'){
	if(*(chaine1+cpt)!='-'){;
	cpt2=cpt2-1;
   }
   cpt=cpt+1;
}
return cpt2;
}

/*fonction dessin du pendu*/
void dessin(int m){
int i=92;
switch(m){
	case 2 :gotoxy(29,24);
		puts("/");
		gotoxy(31,23);
		puts("/");
		gotoxy(32,23);
		printf("%c",i);
		gotoxy(34,24);
		printf("%c",i);
		break;

	case 3 :gotoxy(29,24);
		puts("/");
		gotoxy(31,23);
		puts("/");
		gotoxy(32,23);
		printf("%c",i);
		gotoxy(34,24);
		printf("%c",i);
		gotoxy(31,22);
		puts("|");
		gotoxy(31,21);
		puts("|");
		gotoxy(31,20);
		puts("|");
		gotoxy(31,19);
		puts("|");
		gotoxy(31,18);
		puts("|");
		break;

	case 4 :gotoxy(29,24);
		puts("/");
		gotoxy(31,23);
		puts("/");
		gotoxy(32,23);
		printf("%c",i);
		gotoxy(34,24);
		printf("%c",i);
		gotoxy(31,22);
		puts("|");
		gotoxy(31,21);
		puts("|");
		gotoxy(31,20);
		puts("|");
		gotoxy(31,19);
		puts("|");
		gotoxy(31,18);
		puts("|");
		gotoxy(32,17);
		puts("________");
		break;

	case 5 :gotoxy(29,24);
		puts("/");
		gotoxy(31,23);
		puts("/");
		gotoxy(32,23);
		printf("%c",i);
		gotoxy(34,24);
		printf("%c",i);
		gotoxy(31,22);
		puts("|");
		gotoxy(31,21);
		puts("|");
		gotoxy(31,20);
		puts("|");
		gotoxy(31,19);
		puts("|");
		gotoxy(31,18);
		puts("|");
		gotoxy(32,17);
		puts("________");
		gotoxy(39,18);
		puts("|");
		break;

	case 6 :gotoxy(29,24);
		puts("/");
		gotoxy(31,23);
		puts("/");
		gotoxy(32,23);
		printf("%c",i);
		gotoxy(34,24);
		printf("%c",i);
		gotoxy(31,22);
		puts("|");
		gotoxy(31,21);
		puts("|");
		gotoxy(31,20);
		puts("|");
		gotoxy(31,19);
		puts("|");
		gotoxy(31,18);
		puts("|");
		gotoxy(32,17);
		puts("________");
		gotoxy(39,18);
		puts("|");
		gotoxy(39,19);
		puts("O");
		break;

	case 7 :gotoxy(29,24);
		puts("/");
		gotoxy(31,23);
		puts("/");
		gotoxy(32,23);
		printf("%c",i);
		gotoxy(34,24);
		printf("%c",i);
		gotoxy(31,22);
		puts("|");
		gotoxy(31,21);
		puts("|");
		gotoxy(31,20);
		puts("|");
		gotoxy(31,19);
		puts("|");
		gotoxy(31,18);
		puts("|");
		gotoxy(32,17);
		puts("________");
		gotoxy(39,18);
		puts("|");
		gotoxy(39,19);
		puts("O");
		gotoxy(39,20);
		puts("|");
		gotoxy(39,21);
		puts("|");
		break;

	case 8 :gotoxy(29,24);
		puts("/");
		gotoxy(31,23);
		puts("/");
		gotoxy(32,23);
		printf("%c",i);
		gotoxy(34,24);
		printf("%c",i);
		gotoxy(31,22);
		puts("|");
		gotoxy(31,21);
		puts("|");
		gotoxy(31,20);
		puts("|");
		gotoxy(31,19);
		puts("|");
		gotoxy(31,18);
		puts("|");
		gotoxy(32,17);
		puts("________");
		gotoxy(39,18);
		puts("|");
		gotoxy(39,19);
		puts("O");
		gotoxy(39,20);
		puts("|");
		gotoxy(39,21);
		puts("|");
		gotoxy(38,20);
		puts("/");
		gotoxy(38,22);
		puts("/");
		gotoxy(40,20);
		printf("%c",i);
		gotoxy(40,22);
		printf("%c",i);
		break;
}
}


 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Sources du même auteur

Source avec Zip LECTEUR MP3
Source avec Zip LED CLAVIER
Source avec Zip MORPION
Source avec Zip CALCULETTE NBS COMPLEXE

 Sources de la même categorie

Source avec Zip Source avec une capture JEU DES CARTES par eapaceinfo
PROGRAMME DE JEU DE MPT par KerizGarmm
Source avec Zip Source avec une capture JEUX SERPENT par antho974
Source avec Zip Source avec une capture PENDU EN SDL par Damsou91
Source avec Zip STATE MACHINE MODIFICATION MATH BUCKHAM par billybones79

Commentaires et avis

Commentaire de Disdone le 21/11/2007 20:58:39

fonctionne sur ti ou sur pc???

Commentaire de CrazyGoodBoy le 12/02/2010 21:36:11 1/10

il me donne 11 erreurs

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,406 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales