Files
Borland-C/CPP/PROG7.CPP

124 lines
2.1 KiB
C++
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Prog7
//
// Programadores:
//
// Juan L¢pez Fern ndez
// Moiss Virumbrales Cuenca
// DAI 1§A
//
// Pinta una espiral con el caracter introducido y pinta sus diagonales.
#include <stdio.h>
#include <conio.h>
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();
}