ayuda con graficos please

norma
13 de Abril del 2006
ALGUIEN ME PODRIA AYUDAR, NO SE COMO CREAR UNA GRAFICA EN
C++ EN BASE A LA ECUACION y=x³, YA ESTUVE CHECANDO VARIAS
PAGINAS DE INTERNETT, PERO CAREZCO DE CIERTOS CONOCIMIENTOS
PORQUE POR EJEMPLO ENCONTRE EL SIG. CODIGO:
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <time.h>

/* si x=0 entonces x=0; si x<0 entonces x = -1; si x>0 entonces x=1 */
#define signo(x) ((x<0)?-1:((x>0)?1:0))

int main()
{
int x1=0, x2=319, y1=0, y2=199, dx, dy, dxabs, dyabs, sdx, sdy, i;
union REGS linea;
float pendiente;
clock_t reloj1, reloj2;

/* Modo de video 13h */
linea.h.ah = 0x00;
linea.h.al = 0x13;
int86(0x10, &linea, &linea);

dx = x2-x1; /* distancia horizontal */
dy = y2-y1; /* distancia vertical */
dxabs = abs(dx);
dyabs = abs(dy);
sdx = signo(dx);
sdy = signo(dy);

if(dxabs>=dyabs)
{
pendiente = (float)dy / (float)dx;
for (i=0; i!=dx; i+=sdx)
{
reloj1 = clock();
linea.h.ah = 0x0C; /* funcion para imprimir un pixel */
linea.h. al = 2; /* color verde */
linea.x.cx = i+x1;
linea.x.dx = (pendiente*i)+y1;
int86(0x10, &linea, &linea);
do
reloj2 = clock();
while((reloj2-reloj1)<25);
}
}
else
{
pendiente = (float)dx / (float)dy;
for (i=0; i!=dy; i+=sdy)
{
reloj1 = clock();
linea.h.ah = 0x0C; /* funcion para imprimir un pixel */
linea.h.al = 4; /* color rojo */
linea.x.cx = (pendiente*i)+x1;
linea.x.dx = i+y1;
int86(0x10, &linea, &linea);
do
reloj2 = clock();
while((reloj2-reloj1)<25);
}
}

/* implementa un retardo de tiempo de 2 segundos */
reloj1 = clock();
do
reloj2 = clock();
while((reloj2-reloj1)<2000);

/* retorna a modo de video 3 */
linea.h.ah = 0x00;
linea.h.al = 0x03;
int86(0x10, &linea, &linea);

return 0;
}

Y MI PROBLEMA ES EL SIGUIENTE:


/*GRAFICAR LA ECUACION y=x³ PARA LOS VALORES ENTRE -5 Y
5, EN INCREMENTOS DE 0.5 LOS VALORES MAXIMOS SON DE +125
Y -125*/

MI SOLUCION ES:

#include<iostream.h>
#include<stdio.h>
#include<math.h>

void main()
{

float y, x;

for(x=-5; x<=5; x++)
{
y=(pow(-x, 3));

printf("sus resultados son:%f\n", y);

}

for(x=-4.5; x<=4.5; x++)
{

y=(pow(-x, 3));
printf("sus resultados son:%f\n", y);

}
}

SI EXISTE UN ALMA CARITATIVA QUE ME PUEDE AYUDAR ESTARE MUY AGRADECIDA.