Red de conocimiento informático - Material del sitio web - Proporcione un diagrama de flujo aproximado del programa y corrija algunos errores.

Proporcione un diagrama de flujo aproximado del programa y corrija algunos errores.

void circulo_ad( int x , int y , int r )

{ float a , b , n , j , x1 , y1 , x2 , y2

float c[ 2 ];

n = 0,5*( flotante )r 20; j = 2,0*M_PI/n

a = cos( j );

x1 = ( float )r; y1 = 0;

mientras ( ( int )n gt; = 0 )

{ x2 = x1*a - y1*b; y2 = y1*a x1*b;

c[ 0 ] = x2; c[ 1 ] = y2;

line_dda_1( ( int )x1 , (int)y1 , ( int)x2, (int)y2, x, y, 0);

x1 = c[ 0 ]; y1 = c[ 1 ];

}

}

void círculo_bre( int x , int y , int r , int k )

{ int x1 = 0 ;

int y1 = r;

int d = 2*(x1 1)*(x1 1) (y1-1)*(y1-1) y1*y1-2 *r*r;

for(; x1lt;=y1; x1)

{ if( 153 lt; ( amp; amp; 43 lt; ( y-(int)( (flotante)y1*BI 0.5 ) amp; ( y-(int)( (flotante)y1*BI 0.5 ) lt 305 || int)( (float)y1*BI 0.5 ) )color );

if( 153 lt; ( x y1 ) amp; amp; ( x y1 ) lt; 595 amp; 43 lt; ( y- (int)( (flotante) x1*BI 0,5 ) amp; ( y-(int)( (flotante)x1*BI 0,5 ) lt;| , y-(int)( (flotante)x1*BI 0.5 ) )color

if( 153 lt.( x y1 ) amp; amp; ( x y1 ) lt; 595 amp; amp; 43 lt; ( y (int)( (flotante)x1*BI 0,5 ) ) amperio 0,5 ) ) lt;| float)x1*BI 0.5 ) , color

if( 153 lt ., color );

if( 153 lt; ( x x1 ) amp; ( x x1 ) lt; 595 amp; 43 lt; ( y (int)( (flotador)y1*BI 0.5 ) amp; amp; (int)( (flotador) )y1*BI 0.5 ) ) lt; 305 || k )

putpixel( x x1 , y (int)( (flotante)y1*BI 0.5 ) )color

if( 153 lt; ( x-x1 ) amp; amp; ( x-x1 ) lt; 595 amp; amp; 43 lt; ( y (int)( (flotador)y1*BI 0.5 ) amp ;amp; ( y ( int)( (flotante)y1*BI 0.5 ) ) lt; 305 | k )

putpixel ( x-x1 , y (int)( (flotante)y1*BI 0.5 ) ), color );

if( 153 lt; ( x-y1 ) amp; ( x-y1 ) lt; 595 amp; 43 lt; ( y (int)( (flotador) x1*BI 0.5 ) ) lt; ( y (int)( (flotante)x1*BI 0.5 ) lt; 305 | k )

si ( amp; amp; ( y (int)( (flotante )x1*BI 0.5 ) ) lt; | | k )

putpixel( x-y1 , y (int)( (flotante)x1*BI 0.5 ) , color

while( n gt; 0 )

{ x2 = x1 * c - y1 * ( flotante )a / ( flotante )b * s

y2 = y1 * c x1 * (flotante)b / (flotante)a * s;

line_dda(x1 x, y-y1, x2 x, y- y2, 0);

x1 = x2; n -= 1;

}

}

y2 = ( int )y1;

si( 153 lt; ( x2 x ) amperio (x2 x) lt; 595 amperio 43 lt; (y-y2) amperio; (y-y2) lt; color );

si( 153 lt; ( x2 x ) amp; ( x2 x ) lt; 595 amp; 43 lt; ( y y2 ) amp; amp; ( y y2 ) lt; 305 || k )

putpixel( x x2 , y y2 , color

while( b1 *b1*x1 lt; a1*a1*y1 )

{ si( d lt; 0 )

{ d = d 2*b1*b1*x1 b

1*b1;

x1 = 1.0;

x2 = (int)x1; if( 153 lt; ( x2 x ) amp; ( x2 x ) lt; 595 amp; 43 lt; ( y-y2 ) amp; amp; ( y-y2 ) lt; 305 ||k )

putpixel( x2 x , y-y2 , color );

if( 153 lt; ( x2 x ) amp; ( x2 x ) lt; 595 amp; 43 lt ; ( y y2 ) amp; amp ; ( y y2 ) lt; 305 ||k )

putpixel( x2 x , y y2 , color ); x-x2 ) lt; 595 amperio 43 lt; ( y y2 ) amperio ( y y2 ) lt;

putpixel ( x-x2 , y y2 ) ; >

if( 153 lt; ( x-x2 ) amp; ( x-x2 ) lt; 595 amp; 43 lt; ( y- y2 ) amp; amp; ( y-y2 ) lt; 305 ||k )

putpixel( x-x2 , y-y2 , color

}

else

{ d = d - 2*); a1*a1*y1 2*b1*b1*x1 b1*b1;

x1 = 1,0;

y1 -= 1,0; )x1;

y2 = ( int ) y1;

si( 153 lt; ( x x2 ) amp; amp; ( x x2 ) lt; 595 amp; amp; 43 lt ; ( y-y2 ) amp; x , y-y2 , color ) )

if( 153 lt; ( x x2 ) amp; ( x x2 ) lt; 595 amp; 43 lt; ( y y2 ) amp; amp ; ( y y2 ) lt; 305 ||k )

putpixel( x2 x , y y2 , color );

if( 153 lt; ( x-x2 ) amp; amp; ) lt; 305 ||k )

putpixel( x-x2 , y y2 , color

if( 153 lt; ( x -x2) amperio; (x-x2) lt; 595 amperio;

; ( y-y2 ) lt; 305 ||k )

putpixel( x-x2 , y-y2 , color ); p> if( b1*b1*x1 gt; = a1*a1*y1 )

d = d 3*( a1*a1 - b1*b1 )/4 - ( b1*b1*x1 a1* a1*y1 );

while( b1*b1*x1 gt;= a1*a1*y1 amp;amp; y1 gt; 0.0)

{ if( d gt;= 0 )

{ d = d - 2*a1*a1*y1 a1*a1;

y1 -= 1.0

x2 = ( int )x1; ;

y2 = (int)y1;

if( 153 lt; ( x2 x ) amp; ( x2 x ) lt; 595 amp; 43 lt; ( y-y2 ) amplificador; (y-y2) lt; 305 |k)

putpixel( x2 x, y-y2, color

if( 153 lt; (x2 x) amperio (x2 x) lt; 595 amperio 43 lt; (y y2) amperio; (x) -x2 ) lt; 595 amperios; 43 lts; ( y y2 ) amperios ; ( y y2 ) lt;

if( 153 lt; ( x- x2 ) amp;amp;( x-x2 ) lt;595 amp;amp; 43 lt; ( y-y2 ) amp; amp; ( y-y2 ) lt; 305 ||k )

putpixel( x -x2, y-y2, color);

}

else

{ d = d 2*b1*b1*x1 - 2*a1*a1 *y1 a1*a1;

x1 = 1.0

y1 -=

x2 = ( int )x1;

y2 = (int)y1;

si( 153 lt; ( x x2 ) amp; ( x x2 ) lt; 595 amp; 43 lt; (y-y2) amp; (y-y2) lt; > if( 153 lt; ( x x2 ) amp; amp; amp; y2 = ( int ) x1;

if( 153 lt; ( x x2 ) amp; amp; amp; amp; amp; ( x x2 ) lt; 595 amperios

; amp; 43 lt; ( y y2 ) amp; ( y y2 ) lt;

putpixel( x2 x , y y2 , color ); if( 153 lt; ( x-x2 ) amp; amp; ( x-x2 ) lt; 595 amp; amp; 43 lt; ( y y2 ) amp; amp; ( y y2 ) lt; 305 ||k )

putpixel( x-x2 , y y2 , color );

if( 153 lt; ( x-x2 ) amp; amp; ( x-x2 ) lt; 595 amp; amp; 43 lt (y-y2) amp; (y-y2) lt; 305 ||k

putpixel( x-x2 , y-y2 , color ); > }

}

}

void juxing( int x1 , int y1 , int x2 , int y2 )

{ line_dda( x1, y1, x2, y1, 1);

line_dda(x2, y1, x2, y2, 1);

line_dda(x2, y2, x1, y2, 1) ;

line_dda( x1 , y2 , x1 , y1 , 1

}

void clear( int x1 , int y1 ); x2, int y2)

{ int min, i;

color = 0;

min = abs(y1 - y2) gt; - x2 ) ?abs( x1 - x2 ):

for( i = 0 ; i lt; ( min 2 )/2 ; i )

juxing( x1 i , y1 i , x2 - i , y2 - i );

color = 9

}

principal()

{

int gdriver = VGA;

int gmodel = VGAMED

int textlong = 0;

int textwide = 20; p> int minlong = 37;

int minwide = 37;

int maxlong = 601;

int maxwide = 311; int botónx = 40;

int botóny = 40;

int negrox1 = 153;

int negroy1 = 43; = 595;

int blacky2 = 305;

int colores = 5;

int arriba = 304

int izquierda = 154; ;<

/p>

int select = 0;

int página = 0;

int clave

int i = 0; p> int k = 0;

int x = 0;

int y = 0;

int x1 = 0; int y1 = 258;

int x2 = 0;

int y2 = 0;

int datos = 0; = 0;

int seguro = 0;

int salida = NO;

int pixelx = 0

int pixely = 0;

int píxeles;

int a[ 600 ];

char b[ 10 ];

char d[ 10 ];

char e[ 10 ];

char help[] = "ESC-salir I/K- seleccionar W/S /A/D-mover ESPACIO-seguro R-eliminar H-renovar C-borrar 0/9-color ";

clrscr();

printf( "lt;lt; My Paint 1.2gt;gt; El programa es producido por Jadelight.

autor - LJL\n\n" );

printf( "Ingrese el número de puntos de píxel (1-5): " );

scanf( "d" , amp; píxeles

p>

printf( "gt;"

}

printf( "[OK]" ); ;

dormir( 2 );

mientras( píxeles gt; 5 || píxeles lt; 1 )

píxeles = 5; > registrarbgidriver( EGAVGA_driver );

initgraph( amp; gdriver , amp; gmodel , ""

while( SÍ )

{ setactivepage( página ) ;

clearviewport();

for( k = 0 ; k lt; 2 ; k )

juxing( k , k , getmaxx() - k , getmaxy() - k );

setcolor( ROJO );

outtextxy( textlong 474 , textwide , "Jadelight"

line_dda( textlong 20); , textwide 3 , textlong 160*3 - 10 , textwide 3 , 1 ;

line_dda( textlong 474 textwidth("Jadelight") 2 , textwide 3 , textlong getmaxx() - 20 , textwide 3 , 1 );

for( i=0; ilt; 3; i)

{ juxing( minlong i, minwide i, maxlong-i, maxwide-i);

line_dda( botónx 107 i , botóny , botónx 107 i , maxwide-3 , 1

}

for( i=1 ; ilt; 9 ; i ) <); /p>

line_dda( botónx, botón 30*i, botónx 109, botón 30*i, 1

for( i=0; ilt; 8; i)

<); p> juxing( botónx 2, botón i*30 3. botónx 104, botón i*30 27);

setcolor(AZUL CLARO);

if(select == 0)

SHEZ1

line_dda( botónx 8, botón 8, botónx 20, botón 20, 1);

outtextxy( botón

nx 30, buttony 15, "Dda");

SHEZ2

if( select == 1)

SHEZ1

line_dda ( botónx 8, botón 8 30, botónx 20, botón 20 30, 1);

outtextxy( botónx 30, botón 30 15, "Bresenham");

SHEZ2

if( select == 2 )

SHEZ1

círculo_bre( botónx 15 , botón 60 15 , 8 , 1

outtextxy( botónx 30 ); , botón 60 15 , "Ángulo");

SHEZ2

if( select == 3 )

SHEZ1

círculo_bre( botónx 15, botón 60 15 30, 8, 1);

outtextxy( botónx 30, botón 90 15, "Bresenham");

SHEZ2

if( seleccione == 4 )

SHEZ1

ellipse_bre( botónx 15 , botón 120 15 , 8 , 5 , 1

outtextxy( botónx 30 , botón 120 ); 15, "Ángulo");

SHEZ2

if( select == 5)

SHEZ1

ellipse_bre( botónx 15, botón 120 15 30, 8, 5, 1);

outtextxy( botónx 30, botón 150 15, "Bresenham");

SHEZ2

if( seleccionar == 6 )

SHEZ1

juxing( botónx 5 , botón 180 10 , botónx 25 , botón 180 20

outtextxy( botónx 30 , botón 180 ); 15, "Rectángulo");

SHEZ2

if( select == 7)

SHEZ1

outtextxy( botónx 30, botón 210 15 , "Acerca de" );

SHEZ2

setfillstyle( SOLID_FILL , RED );

Floodfill( botónx 1 , selección de botones*30 2 , AZUL CLARO ) ;

juxing(negrox1, negro1, negrox2, negro2);

line_dda( 0 , getmaxy()-25 , getmaxx() , getmaxy()-25 , 1

setcolor( MAGENTA

outtextxy); (textlong 9, getmaxy()-15, ayuda);

for( i = 0; i lt; data/6; i)

{ if( a[ i*6 ] == 0 )

{ color = a[ i*6 5 ]

line_dda( a[ i*6 1 ] , a[ i*6 2 ] , a[ i*6 3 ] , a[ i*6 4 ] , 1

}

más si( a[ i*6 ] == 1 )

{ color = a[ i*6 5 ];

line_dda( a[ i*6 1 ] , a[ i*6 2 ] , a[ i*6 3 ] , a[ i* 6 4 ] , 1 );

}

más si( a[ i*6 ] == 2 )

{ color = a[ i*6 5 ];

círculo_ad( a[ i*6 1 ] , a[ i*6 2 ] , abs( a[ i*6 3 ] - a[ i*6 1 ] )

}

else if( a[ i*6 ] == 3 )

{ color = a[ i*6 5 ];

circulo_bre( a [ i *6 1 ] , a[ i*6 2 ] , abs( a[ i*6 3 ] - a[ i*6 1 ] ) ,

}

<); p> else if( a[ i*6 ] == 4 )

{ color = a[ i*6 5 ];

if( a[ i*6 1 ] - a[ i*6 3 ] == 0 )

line_dda( a[ i*6 1 ] , a[ i*6 2 ] , a[ i*6 1 ] , a[ i*6 2 ] 2 * ( a[ i*6 4 ] - a[ i*6 2 ] ) , 0 );

else if( a[ i*6 2 ] - a[ i*6 4 ] = = 0 )

line_dda( a[ i*6 3 ] , a[ i*6 4 ] , a[ i*6 3 ] - 2 * ( a[ i*6 3 ] - a[ i *6 1 ] ), a[ i*6 2 ] , 0

else

ellipse_ad( a[ i*6 1 ] , a[ i*6 4 ] , abs( a[ i*6 3 ] - a[ i*6 1 ] ), abs( a[ i*6 4 ] - a[ i*6 2 ]

}

);

else if( a[ i*6 ] == 5 )

{ color = a[ i*6 5 ];

if( a[ i*6 1 ] - a[ i*6 3 ] == 0 )

line_dda(

a[ i*6 1 ] , a[ i*6 2 ] , a[ i*6 1 ] , a[ i*6 2 ] 2 * ( a[ i*6 4 ] - a[ i*6 2 ] ) , 0);

else if( a[ i*6 2 ] - a[ i*6 4 ] == 0 )

line_dda( a[ i*6 3 ] , a[ i*6 4 ] , a[ i*6 3 ] - 2 * ( a[ i*6 3 ] - a[ i*6 1 ] ) , a[ i*6 2 ] , 0 );

else

ellipse_bre( a[ i*6 1 ] , a[ i*6 4 ] , abs( a[ i*6 3 ] - a[ i*6 1 ] ), abs ( a[ i*6 4 ] - a[ i*6 2 ] ) , 0

}

else if( a[ i*6 ] == 6 )

{ color = a[ i*6 5 ];

juxing( a[ i*6 1 ], a[ i*6 2 ] , a[ i*6 3 ] , a[ i*6 4 ] );

}

}

}

si( colores == 1 )

{ setcolor( AZUL );

outtextxy( buttonx-3 , getmaxy()-33 , "Azul"

}

else); if( colores == 2 )

{ setcolor( VERDE

outtextxy( buttonx-3 , getmaxy()-33 , "Verde"

}

else if( colores == 3 )

{ setcolor( CYAN

outtextxy( buttonx-3 , getmaxy()-33 , " Cian" ​​);

}

else if( colores == 4 )

{ setcolor( ROJO );

outtextxy( botónx -3, getmaxy()-33, "Rojo");

}

else if( colores == 5)

{ setcolor(MAGENTA);

outtextxy( botónx-3 , getmaxy()-33 , "Magenta");

}

else if( colores == 7 )

{ setcolor( BLANCO

outtextxy( botónx-3 , getmaxy()-33 , "Blanco"

}

);

else if( colores == 8 )

}

{ setcolor( GRIS OSCURO );

<

p> outtextxy( botónx-3 , getmaxy()-33 , "Gris oscuro"

}

else if( colores == 9 )

{ setcolor( AZUL CLARO );

outtextxy( botónx-3 , getmaxy()-33 , "Azul claro"

}

else if( colores == 10)

{ setcolor( VERDE CLARO );

outtextxy( botónx-3 , getmaxy()-33 , "Verde claro"

}

else if( colores == 14 )

{ setcolor( AMARILLO );

outtextxy( buttonx-3 , getmaxy()-33 , "Amarillo");

}

if( seguro == SÍ )

{ if( colores != 7 )

putpixel( x , y , colores

else

putpixel( x , y , colores 8

sprintf( d , "d" , x2 ); p> sprintf( e , "d" , y2 );

outtextxy( botónx 20 , botón 240 5 , d

outtextxy( botónx 60 , botón 240 5 , e ); ;

}

sprintf( b , "d" , pixelx

sprintf( c , "d" , pixely ); p> setcolor(MAGENTA);

outtextxy(botónx 20, botón 240 20, b);

outtextxy(botónx 60, botón 240 20, c

<); p> color = 2;

line_dda( izquierda, arriba, izquierda 3, arriba, 0

line_dda( izquierda, arriba, izquierda-3, arriba, 0 ); /p>

line_dda( izquierda, arriba, izquierda, arriba 3, 0

line_dda( izquierda, arriba, izquierda, arriba-3, 0 ); = 9;

if( salida == SÍ )

{ setcolor( MAGENTA

if( página == SÍ )

outtextxy( buttonx 405, getmaxy()-33, "¿Estás saliendo?lt;Y/Ngt;");

}

if( select == 7)

{ color = 7;

juxing( blackx1 77 , blacky1 77 , blackx2 - 75 , blacky2-75 );

setfillstyle( SOLID_FILL , LIGHTGRAY );

relleno de inundación( blackx1 78, blacky1 78, LIGHTGRAY

color = 15

for( i = 0; i lt; 2; i)

juxing( negrox1 82 i*2 , negroy1 80 i*2 , negrox2 - 80 - i*2 , negroy2 - 78 - i*2

setcolor( 0 ); /p>

outtextxy( blacky2 40, 140, "Mi pintura");

outtextxy( blacky2 22, 170, "Versión 2.0");

outtextxy( blacky2 - 40, 185, "Copyright (c) 2004 - 2005 por");

outtextxy(blacky2 - 40, 200, "Únase a la corporación autor-LJL.");

color = 9;

}

setvisualpage( página );

página = SÍ - página

si ( salir == NO )

{ if( kbhit() )

{ if( ( key = getch() ) == ESC )

salir = YES;

else if( clave == 'i' || clave == 'I' || clave == 'j' || clave == 'J' )

{ if( select == 0 )

seleccione = 7;

más

seleccione--; == 'k' || clave == 'K' || clave == 'l' || clave == 'L' )

{si(seleccionar == 7 )

seleccionar = 0;

más

seleccionar ;

}

más si (tecla == 'w' || clave == 'W' )

{ if( arriba lt; = blacky1 1

else

{ arriba -= píxeles;

<); p> y1 -= píxeles;

pixely = arriba;

pixely = 304 - pixely;

if( seguro == SÍ )

y2 = abs( arriba - y );

}

}

más

if( clave == 's' || clave == 'S' )

{ if( up gt; = blacky2 - 1 );

else

{ arriba = píxeles;

y1 = píxeles;

pixely = arriba;

pixely = 304 - pixely; seguro == SÍ )

y2 = abs( arriba - y );

}

}

si no (clave == 'a' || tecla == 'A' )

{ if( left lt; = blackx1 1 );

else

{ left -= píxeles ;

x1 -= píxeles;

pixelx = izquierda;

pixelx -= 154;

si (seguro == SÍ)

x2 = abs( izquierda - x

}

}

else if( tecla == 'd' | tecla == 'D' )

{ if(left gt; = blackx2 - 1);

else

{ left = píxeles;

x1 = píxeles;

pixelx = izquierda;

pixelx -=

si (seguro == SÍ)

x2 = abs( izquierda - x );

}

}

else if( clave == 'c' | clave == 'C' )

{ clear( negrox1 1 , blacky1 1 , blackx2-1 , blacky2-1 ​​​​

datos = 0

renovar = 0; p>

}

else if( clave == 0x20 )

{ if( seguro == NO amp; select != 7 )

{ x = izquierda; y = arriba;

seguro = YES;

}

else if( seguro == YES amp; amp; select ! = 7 )

{ a[ datos 1 ] = x ; a[ datos 2 ] = y

a[ datos 3 ] = izquierda ; a[ datos 4 ] = arriba; >

a[ datos ] = seleccionar;

if( colores ! = 7 )

a[ datos 5 ] = colores

else

a[ datos 5 ] = colores

seguro; = NO;

datos = 6

renovar = 0;

x2 = 0

y2;

= 0;

}

}

else if( clave gt; = '0' amp; clave lt; = '9' )

{ if( clave != '5' )

colores = clave - 47;

else

colores = 14;

}

else if( clave == 'r' || clave == 'R' )

{ if( data gt; 0 )

{ datos -= 6;

renovar

}

}

más si (clave == 'h' | | clave == 'H' )

{ if( renovar gt; 0 )

{ datos = 6;

renovar--;

} >>

}

mientras( kbhit() )

getch()

}

}

else if( kbhit() )

{ key = getch();

if( key == 'n' || key = = ' N' || clave == ESC )

salir = NO;

if( clave == 'y' || clave == 'Y' )

romper;

}

}

clear( 0 , 0 , getmaxx() , getmaxy()

closegraph(); );

}