Título: CREAR UNA PERSONA EN [C++]
Publicado por: KFMaguz en 5 Mayo 2008, 18:05 pm
Construya un programa en C que permita crear el retrato hablado de un individuo considerando que el usuario ingresa las siguientes opciones: • Alto de la figura, es decir, ingresa la estatura que debe tener el dibujo, ejm. Si ingresa un 10 significa que la altura desde los hombros a la cintura, de la cintura al suelo y la medida de los brazos debe ser de 5, es decir (10/2). • Tipo de cabello de la figura, Peinado IIIIIIIII, despeinado @@@@@@@@@ o natural wwwwwwwww • Con o sin lentes, con lentes I ‐ (O O)‐ I, sin lentes I O O I • Contento o triste, Contento \______/, triste _______ / \ • Color que desea que posean el chaleco y pantalón (debe poner a disposición tres opciones de colores para cada artículo de la vestimenta). • El usuario debe tener la oportunidad de arrepentirse si no le gusto el retrato del individuo y volver a crear un individuo sin salir de programa. printf ("Esta conforme con el retrato?"); printf (Ingrese 1=Conforme o 2=Desconforme); • El usuario debe tener la oportunidad de repetir el programa sin salirse. printf ("Desea crear otro individuo?"); printf ("Ingrese 1=si 2=no");
Algo asi tiene que quedar
(http://img509.imageshack.us/img509/9609/dibujoos6.png)
Solucion: Ya esta resuelto este ejercicio se los deje mas abajo ^^
Título: Re: CREAR UNA PERSONA EN [C++]
Publicado por: KFMaguz en 14 Mayo 2008, 18:10 pm
Editado: Abajo esta el programa completo
Título: Re: CREAR UNA PERSONA EN [C++]
Publicado por: Casidiablo en 14 Mayo 2008, 18:40 pm
CREAR UNA PERSONA EN [C++]??? Jugando a ser Dios???
Debes poner lo que has intentado!
Título: Re: CREAR UNA PERSONA EN [C++]
Publicado por: KFMaguz en 16 Mayo 2008, 05:30 am
Editado: Abajo esta el programa completo
Título: Re: CREAR UNA PERSONA EN [C++]
Publicado por: Casidiablo en 16 Mayo 2008, 18:52 pm
Pero que sale??? Que error?
Título: Re: CREAR UNA PERSONA EN [C++]
Publicado por: KFMaguz en 17 Mayo 2008, 20:21 pm
Editado: Abajo esta el programa completo
Título: Re: CREAR UNA PERSONA EN [C++]
Publicado por: barbate en 18 Mayo 2008, 17:39 pm
Tienes que reservar mas espacio en los arrays.
Título: Re: CREAR UNA PERSONA EN [C++]
Publicado por: barbate en 18 Mayo 2008, 17:45 pm
tambien te falta por incluir una libreria.
s2
Título: Re: CREAR UNA PERSONA EN [C++]
Publicado por: chrominum en 18 Mayo 2008, 18:11 pm
Instala la librería conio
Título: Re: CREAR UNA PERSONA EN [C++]
Publicado por: Lambda en 18 Mayo 2008, 18:45 pm
es conio.h no conio.c ;D
Título: Re: CREAR UNA PERSONA EN [C++]
Publicado por: Ragnarok en 18 Mayo 2008, 18:55 pm
No necesitas conio para nada, con poner espacios al principio de cada cadena vale.
Título: Re: CREAR UNA PERSONA EN [C++]
Publicado por: KFMaguz en 19 Mayo 2008, 05:14 am
es conio.h no conio.c En realidad agrege unos archivos a la carpeta include del dev-c++ para ocupar esa libreria :) El ejecutable corre con estos codigos :D Ragnarok: "Felicidades. Publícalo si quieres pero, aparte de que este mensaje no añade nada al hilo, se salta las normas, por eso he quitado el estilo a la letra. Recuerda revisar las normas" Disculpa, solo vi el boton de esa letra y me gusto.
Aca como lo prometi les traigo 2 codigos del mismo ejercicio. Una es la mia y otra la de un compañero ^^ ambos estran buenos, x si alguien lo quiere realizar :D Este es el mio #include <conio.c> #include <stdio.h> int estatura, pelo, ojos, boca, chaleco, pantalon; int control=1; int repetir=1; int opcion; int main(){ while(repetir==1) { textcolor(9); printf("\n:::::PROGRAMA PARA CREAR RETRATO DE UN INDIVIDUO:::::\n"); textcolor(10); printf("\n\n\Como es la estatura del individuo:\n"); textcolor(15); printf("1)Chico: Menor o igual a 1.50mt\n2)Mediano: Mayor a 1.50mt y menor o igual a 1.75mt\n3)Alto: Mayor a 1.75mt\n"); textcolor(14); printf("Respuesta:"); textcolor(15); scanf ("%d", &opcion); while(control==1) { switch (opcion) { case 1: estatura=1; control=0; break; case 2: estatura=2; control=0; break; case 3: estatura=3; control=0; break; default: textcolor(12); printf("\nERROR:"); textcolor(15); printf("No existe esa opcion\nVuelva a elegir\n"); textcolor(10); printf("\n\n\Como es la estatura del individuo:\n"); textcolor(15); printf("1)Chico: Menor o igual a 1.50mt\n2)Mediano: Mayor a 1.50mt y menor o igual a 1.75mt\n3)Alto: Mayor a 1.75mt\n"); textcolor(14); printf("Respuesta:"); textcolor(15); scanf ("%d", &opcion); break; } }
textcolor(10); printf("\n\nComo es el Pelo del individuo: \n"); textcolor(15); printf("1)Natural \n2)Ondulado \n3)Peinado\n"); textcolor(14); printf("Respuesta:"); textcolor(15); control=1; scanf ("%d", &opcion); while(control==1) { switch (opcion) { case 1: pelo=1; control=0; break; case 2: pelo=2; control=0; break; case 3: pelo=3; control=0; break; default: textcolor(12); printf("\nERROR:"); textcolor(15); printf("No existe esa opcion\nVuelva a elegir\n"); textcolor(10); printf("\n\nComo es el Pelo del individuo: \n"); textcolor(15); printf("1)Natural \n2)Ondulado \n3)Peinado\n"); textcolor(14); printf("Respuesta:"); textcolor(15); scanf ("%d", &opcion); break; } }
textcolor(10); printf("\n\nEl individuo usa Lentes:"); textcolor(15); printf("\n1)No, no usa lentes \n2)Si, si usa lentes\n"); textcolor(14); printf("Respuesta:"); textcolor(15); scanf ("%d", &opcion); control =1; while(control==1) { switch (opcion) { case 1: ojos=1; control=0; break; case 2: ojos=2; control=0; break; default: textcolor(12); printf("\nERROR:"); textcolor(15); printf("No existe esa opcion\nVuelva a elegir\n"); textcolor(10); printf("\n\nEl individuo usa Lentes:"); textcolor(15); printf("\n1)No, no usa lentes \n2)Si, si usa lentes\n"); textcolor(14); printf("Respuesta:"); textcolor(15); scanf ("%d", &opcion); break; } }
textcolor(10); printf("\n\nEstado de animo del individuo:"); textcolor(15); printf("\n1)Feliz \n2)Normal\n3)Triste\n"); textcolor(14); printf("Respuesta:"); textcolor(15); scanf ("%d", &opcion); control =1; while(control==1) { switch (opcion) { case 1: boca=1; control=0; break; case 2: boca=2; control=0; break; case 3: boca=3; control=0; break; default: textcolor(12); printf("\nERROR:"); textcolor(15); printf("No existe esa opcion\nVuelva a elegir\n"); textcolor(10); printf("\n\nEstado de animo del individuo:"); textcolor(15); printf("\n1)Feliz \n2)Normal\n3)Triste\n"); textcolor(14); printf("Respuesta:"); textcolor(15); scanf ("%d", &opcion); break; } }
textcolor(10); printf("\n\nColor del chaleco:"); textcolor(15); printf("\n1)Rojo \n2)Verde\n3)Azul\n"); textcolor(14); printf("Respuesta:"); textcolor(15); scanf ("%d", &opcion); control =1; while(control==1) { switch (opcion) { case 1: chaleco=12; control=0; break; case 2: chaleco=2; control=0; break; case 3: chaleco=1; control=0; break; default: textcolor(12); printf("\nERROR:"); textcolor(15); printf("No existe esa opcion\nVuelva a elegir\n"); textcolor(10); printf("\n\nColor del chaleco:"); textcolor(15); printf("\n1)Rojo \n2)Verde\n3)Azul\n"); textcolor(14); printf("Respuesta:"); textcolor(15); scanf ("%d", &opcion); break; } }
textcolor(10); printf("\n\nColor del pantalon:"); textcolor(15); printf("\n1)Azul Oscuro \n2)Azul\n3)Verde\n"); textcolor(14); printf("Respuesta:"); textcolor(15); scanf ("%d", &opcion); control =1; while(control==1) { switch (opcion) { case 1: pantalon=1; control=0; break; case 2: pantalon=9; control=0; break; case 3: pantalon=2; control=0; break; default: textcolor(12); printf ("\nERROR:"); textcolor(15);printf("No existe esa opcion\nVuelva a elegir\n"); textcolor(10); printf("\n\nColor del pantalon:"); textcolor(15); printf("\n1)Azul Oscuro \n2)Azul\n3)Verde\n"); textcolor(14); printf("Respuesta:"); textcolor(15); scanf ("%d", &opcion); break; } }
textcolor(9); printf("\n\n::::::::::ESTE ES EL RETRATO DE SU INDIVIDUO::::::::::\n\n"); textcolor(6); if (pelo==1) printf (" WWWWWWWWWW \n"); if (pelo==2) printf (" @@@@@@@@@@ \n"); if(pelo==3) printf (" |||||||||| \n"); textcolor(7);
printf (" | |\n"); //imprimir frente
if (ojos==1) printf (" @| O O |@\n"); if (ojos==2) printf (" @|-(o)(o)-|@\n");
printf (" | ( |\n"); //imprime nariz
if (boca==1) printf (" | \\____/ |\n"); if (boca==2) printf (" | ---- |\n"); if(boca==3) printf (" | ----¿ |\n");
printf (" \\______/\n"); //imprime pera
switch (estatura) { case 1: { textcolor(chaleco); printf (" ________"); textcolor(7); printf ("| |"); textcolor(chaleco); printf("________"); textbackground(0); printf (" \n"); textcolor(0); textbackground(0); printf (" "); textbackground(chaleco); printf("| o |"); textbackground(0); printf (" \n"); textbackground(0); printf (" "); textbackground(chaleco); printf ("| o |"); textbackground(0); printf (" \n"); textbackground(0); printf (" "); textbackground(chaleco); printf ("| | o | |"); textbackground(0); printf (" \n"); textbackground(0); printf (" "); textbackground(chaleco); printf ("| | o | |"); textbackground(0); printf (" \n"); textbackground(0); printf (" "); textbackground(chaleco); printf ("| | o | |"); textbackground(0); printf (" \n"); textbackground(0); printf (" "); textbackground(chaleco); printf ("| | o | |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(7); printf (" uuuu"); textcolor(0); textbackground(chaleco); printf ("|_______o_______|"); textbackground(0); textcolor(7); printf ("uuuu"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| | |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| | |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| | |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| | |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("|_______|_______|"); textbackground(0); printf (" \n"); textbackground(0) ;textcolor(7); printf (" |_____| |_____|"); textbackground(0); printf (" \n\n"); break; }
case 2: { textcolor(chaleco); printf (" ________"); textcolor(7); printf ("| |"); textcolor(chaleco); printf("________"); textbackground(0); printf (" \n"); textcolor(0); textbackground(0); printf (" "); textbackground(chaleco); printf("| o |"); textbackground(0); printf (" \n"); textbackground(0); printf (" "); textbackground(chaleco); printf ("| o |"); textbackground(0); printf (" \n"); textbackground(0); printf (" "); textbackground(chaleco); printf ("| | o | |"); textbackground(0); printf (" \n"); textbackground(0); printf (" "); textbackground(chaleco); printf ("| | o | |"); textbackground(0); printf (" \n"); textbackground(0); printf (" "); textbackground(chaleco); printf ("| | o | |"); textbackground(0); printf (" \n"); textbackground(0); printf (" "); textbackground(chaleco); printf ("| | o | |"); textbackground(0); printf (" \n"); textbackground(0); printf (" "); textbackground(chaleco); printf ("| | o | |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(7); printf (" uuuu "); textcolor(0); textbackground(chaleco); printf ("I O I"); textbackground(0); textcolor(7); printf (" uuuu"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(chaleco); printf("|_______o_______|"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| | |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| | |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| | |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| | |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| | |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("|_______|_______|"); textbackground(0); printf (" \n"); textbackground(0) ;textcolor(7); printf (" |_____| |_____|"); textbackground(0); printf (" \n\n"); break; } case 3: { textcolor(chaleco); printf (" ________"); textcolor(7); printf ("| |"); textcolor(chaleco); printf("________"); textbackground(0); printf (" \n"); textcolor(0); textbackground(0); printf (" "); textbackground(chaleco); printf("| o |"); textbackground(0); printf (" \n"); textbackground(0); printf (" "); textbackground(chaleco); printf ("| o |"); textbackground(0); printf (" \n"); textbackground(0); printf (" "); textbackground(chaleco); printf ("| | o | |"); textbackground(0); printf (" \n"); textbackground(0); printf (" "); textbackground(chaleco); printf ("| | o | |"); textbackground(0); printf (" \n"); textbackground(0); printf (" "); textbackground(chaleco); printf ("| | o | |"); textbackground(0); printf (" \n"); textbackground(0); printf (" "); textbackground(chaleco); printf ("| | o | |"); textbackground(0); printf (" \n"); textbackground(0); printf (" "); textbackground(chaleco); printf ("| | o | |"); textbackground(0); printf (" \n"); textbackground(chaleco); printf ("| | o | |"); textbackground(0); printf (" \n"); textbackground(chaleco); printf ("| | o | |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(7); printf (" uuuu "); textcolor(0); textbackground(chaleco); printf ("| o |"); textbackground(0); textcolor(7); printf (" uuuu"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(chaleco); printf("|_______o_______|"); textbackground(0); printf (" \n");
textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| | |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| | |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| | |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| | |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| | |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| | |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("| | |"); textbackground(0); printf (" \n"); textbackground(0); textcolor(0); printf (" "); textbackground(pantalon); printf("|_______|_______|"); textbackground(0); printf (" \n"); textbackground(0) ;textcolor(7); printf (" I_____I I_____I"); textbackground(0); printf (" \n\n"); break; } } textbackground(0); textcolor(10); printf ("Que desea hacer ahora?:\n"); textcolor(15); printf("Escriba 1 para repetir el programa\n"); printf("O cualquier tecla dintinta de 1 para salir\n"); textcolor(14); printf("Respuesta:"); textcolor(15); scanf ("%i", &control); if (control==1) repetir=1; else repetir=0; } }
Este es el de mi compa: #include <conio.c> #include <stdlib.h> #include <stdio.h>
char frente[25] =" | | "; char ojos[25] =" | O O | "; char nariz[25]=" @| ( |@"; char triste[25] =" | /----\\ |"; char lentes[25]=" |-(o)(o)-| "; char contento[25]=" | \\____/ |"; char pelolais[25]=" |||||||||| "; char pelonormal[25]=" ^^^^^^^^^^ "; char peloondulado[25]=" @@@@@@@@@@ "; int estatura,lente,pelo,cara; int control=1; int repetir=1;
int main(){ while(repetir==1) { do { textcolor(LIGHTGREEN); printf("\n\n\ Ingrese Numero de la opcion de estatura que desea:\n\n"); textcolor(WHITE); printf(" 1 CHICO: menor o igual a 1.50mt\n 2 MEDIANO: mayor a 1.50 y menor o igual a 1.70mt\n 3 ALTO: mayor a 1.70mt\n\n"); printf("Su opcion elegida es: "); scanf("%i",& estatura); if (estatura<1 || estatura>3){ printf ("\n SOLO PUEDE INGRESAR OPCIONES DE 1 a 3\n"); } }while (estatura<1 || estatura >3); clrscr(); do{ textcolor(LIGHTGREEN); printf("\n\n\ Ingrese Numero de la opcion de pelo que desea:\n\n"); textcolor(WHITE); printf(" 1 LISO \n 2 NORMAL \n 3 ONDULADO\n\n"); printf("Su opcion elegida es: "); scanf("%i",& pelo); if (pelo<1 || pelo>3){ printf ("\n SOLO PUEDE INGRESAR OPCIONES DE 1 a 3\n"); } }while (pelo<1 || pelo>3); clrscr(); do{ textcolor(LIGHTGREEN); printf("\n\n\ Ingrese numero de la opcion de ojos que desea:\n\n"); textcolor(WHITE); printf(" 1 CON lENTES \n 2 SIN LENTES\n\n"); printf("Su opcion elegida es: "); scanf("%i",& lente); if (lente<1 || lente>2){ printf ("\n SOLO PUEDE INGRESAR OPCIONES DE 1 a 2\n"); } }while (lente<1 || lente >2); clrscr(); do{ textcolor(LIGHTGREEN); printf("\n\n\ Ingrese numero de la opcion de cara que desea:\n\n"); textcolor(WHITE); printf(" 1 CONTENTO \n 2 TRISTE \n\n"); printf("Su opcion elegida es: "); scanf("%i",& cara); if (cara<1 || cara>2){ printf ("\n SOLO PUEDE INGRESAR OPCIONES DE 1 a 2\n"); } }while (cara<1 || cara>2); clrscr();
if (pelo==1){gotoxy(20,5); textcolor(YELLOW); cprintf("%s",pelolais);} {gotoxy(20,6); textcolor(LIGHTGRAY); cprintf("%s",frente);} if (pelo==2){gotoxy(20,5); textcolor(YELLOW); cprintf("%s",pelonormal);} {gotoxy(20,6); textcolor(LIGHTGRAY); cprintf("%s",frente);} if (pelo==3){gotoxy(20,5); textcolor(YELLOW); cprintf("%s",peloondulado);} {gotoxy(20,6); textcolor(LIGHTGRAY); cprintf("%s",frente);} if (lente==1){gotoxy(20,7); textcolor(LIGHTGRAY); cprintf("%s",lentes); gotoxy(20,8); cprintf("%s", nariz);} if (lente==2){gotoxy(20,7); textcolor(LIGHTGRAY); cprintf("%s",ojos); gotoxy(20,8); cprintf("%s", nariz);} if (cara==1){gotoxy(20,9); textcolor(LIGHTGRAY); cprintf("%s",contento);} if (cara==2){gotoxy(20,9); textcolor(LIGHTGRAY); cprintf("%s",triste);} textcolor(LIGHTGRAY) ; if(estatura==1){ textcolor(LIGHTGRAY); printf("\n \\_ _/ "); textcolor(RED) ; printf("\n ______| |_____ "); printf("\n / | O \\ "); printf("\n | | O | | "); printf("\n | | O | | "); printf("\n |__| O |__| "); printf("\n !!!|_____O_____|!!! "); textcolor(BLUE) ; printf("\n | | "); printf("\n | | | "); printf("\n | | | "); printf("\n | | | "); printf("\n |_____|_____| ");textcolor(BROWN) ; printf("\n |___| |___| "); }
if(estatura==2){ textcolor(LIGHTGRAY); printf("\n \\_ _/ "); textcolor(RED) ; printf("\n ______| |______ "); printf("\n / \\ "); printf("\n | | O | | "); printf("\n | | | | "); printf("\n | | O | | "); printf("\n | | | | "); printf("\n |__| O |__| "); printf("\n !!!|_____________|!!! "); textcolor(LIGHTBLUE) ; printf("\n | | "); printf("\n | | | "); printf("\n | | | "); printf("\n | | | "); printf("\n |______|______| "); textcolor(BROWN) ; printf("\n |____| |____| ");} if(estatura==3){ textcolor(LIGHTGRAY); printf("\n \\_ _/ "); textcolor(RED) ; printf("\n ________| |_______ "); printf("\n / \\ "); printf("\n | O | "); printf("\n | | | | "); printf("\n | | O | | "); printf("\n | | | | "); printf("\n | | O | | "); printf("\n | | | | "); printf("\n |___| O |___| "); printf("\n !!!|_____________|!!! "); textcolor(LIGHTBLUE) ; printf("\n | | "); printf("\n | | | "); printf("\n | | | "); printf("\n | | | "); printf("\n | | | "); printf("\n | | | "); printf("\n | | | "); printf("\n | | | "); printf("\n | | | "); printf("\n | | | "); printf("\n |______|______| "); textcolor(BROWN) ; printf("\n |____| |____| "); } textcolor(WHITE); system("pause"); clrscr();
textcolor(YELLOW); printf ("QUE OPCION DESEA REALIZAR AHORA:\n"); textcolor(WHITE); printf("\n\n Ingrese:\n\n 1 Para reiniciar el programa\n 2 : para Salir de la aplicacion \n"); scanf ("%i", &control); if (control==1) repetir=1; else repetir=0; clrscr(); } }
Título: Re: CREAR UNA PERSONA EN [C++]
Publicado por: barbate en 21 Mayo 2008, 16:59 pm
muy bien, yo hubiera usado for apra tantas repeticiones, pero si le programa funciona... :)
un saludo
Título: Re: CREAR UNA PERSONA EN [C++]
Publicado por: Crazy.sx en 28 Mayo 2008, 07:32 am
Esta bueno esto che jajaja, y de paso me sirve para poder retomar de nuevo la practica en C (hace bastante que no lo toco).
Solo le falta bailar.... :P :P
Saludos che ;)
|