// Prog7 // // Programadores: // // Juan Ląpez Fern ndez // Mois‚s Virumbrales Cuenca // DAI 1§A // // Pinta una espiral con el caracter introducido y pinta sus diagonales. #include #include char direccion; char caracter; int pos_x,pos_y,avanza,con,veces,avanzamas,sw; void main() { clrscr(); gotoxy (20,11); printf ("Introduzca el car cter a imprimir: "); fflush (stdin); cscanf ("%c", &caracter); //gotoxy (20,12); //printf ("Introduzca el sentido inicial: "); //fflush(stdin); //scanf("%c",&direccion_inicial); clrscr(); direccion='e'; pos_x=40; pos_y=12; avanza=1; //avanzamas=15; gotoxy (pos_x,pos_y); printf ("%c",caracter); do { for (con=1;con<=2;con++) { for (veces=1;direccion=='e' && veces<=avanza;veces++) { gotoxy(pos_x,pos_y); printf("%c",caracter); pos_x++; if (pos_x==50) { sw=1; direccion='p'; } } for (veces=1;direccion=='o' && veces<=avanza;veces++) { gotoxy(pos_x,pos_y); printf("%c",caracter); pos_x--; } for (veces=1;direccion=='n' && veces<=avanza;veces++) { gotoxy(pos_x,pos_y); printf("%c",caracter); pos_y--; } for (veces=1;direccion=='s' && veces<=avanza;veces++) { gotoxy(pos_x,pos_y); printf("%c",caracter); pos_y++; } getch(); // Cambio de direcciones. if (direccion=='e') { direccion='s'; } else { if (direccion=='o') { direccion='n'; } else { if (direccion=='n') { direccion='e'; } else { if (direccion=='s') { direccion='o'; } } } } } //avanzamas++; avanza++; } while (sw==0); gotoxy(80,25); getch(); pos_x=31; pos_y=3; for(con=1;con<=19;con++,pos_x++,pos_y++) { gotoxy (pos_x,pos_y); textcolor(14); cprintf ("%c",caracter); } getch(); pos_x=49; pos_y=3; for(con=1;con<=19;con++,pos_x--,pos_y++) { if (pos_x!=40) { gotoxy (pos_x,pos_y); textcolor(1); cprintf ("%c",caracter); } } getch(); }