HI ALL, I am trying to sketch the beging of function and the end,

#include<ctype.h>
#include<graphics.h>
#include<conio.h>
#include<math.h>
#include<dos.h>
#include<stdio.h>
#include<stdlib.h>

int xmax =1024;// getmaxx();
int ymax =760;// getmaxy();

float r,h;//???
int i;


void grafica(){
//int gd=DETECT, gm;
//initgraph(&gd, &gm, "..\bgi" );
initwindow(xmax,ymax, " Miscare ");
setcolor(15);
}


float f(float x)
{
 return x*x*x;

}


void calcul(float a,float b, float* z)
{
h = fabs(b-a)/(xmax-1);
for(i=0;i<xmax;i++)
 z[i]=f(a+(i-1)*h);

}

void normare(float* z,int* l0,float* vmax,float* vmin)
{

float delta, deplas;
*vmax= *vmin = z[0];
for(i = 0;i<xmax;i++){
if(z[i]> *vmax) *vmax=z[i];
if(z[i]<*vmin) *vmin=z[i];
 }
delta = (*vmax-*vmin)/(ymax);
deplas = 0-*vmin;
*l0=(int)floor(ymax-deplas/delta);//rotungeste
if(*vmin > 0) *l0=415;
if(*vmax < 0) *l0=10;

for(i =0;i<xmax;i++)
z[i]=ymax-(z[i]+deplas)/delta;


}

void axax(int linie0,const float* a,const float* b)
{
 setcolor(11);
 char s[48];
 outtextxy(getmaxx()-15,getmaxy()-10,"X");
 line(20,linie0,getmaxx()-20,linie0);
 h=(*b-*a)/2;

 for(int i=0;i<2;i++)
 {
  fillellipse(20+i*300,linie0,2,2);
  r = *a+i*h;
  snprintf(s,sizeof(s),"%2.1f",r);  //str(r); echivalent
  outtextxy(20+i*290,linie0+10,s);


//  line((int)fabs(r),

  free(s);
 }

}
void axay(const float* vmax,const float* vmin)
{
 setcolor(14);
 outtextxy(10,10,"Y");
 h=(*vmax-*vmin);
 char s[20];
 for(int i=0;i<1;i++){
 fillellipse(20,10+i*400,2,2);
 r=*vmax-i*h;
 snprintf(s,sizeof(s),"%2.1f",r);  //str(r); echivalent
 outtextxy(20,10+i*400,s);
 free(s);
}
line(20,10,20,getmaxy()-65);
}



void modeleazaGrafic(float* y,int linie0,const float* a,const float* b,const float* vmax, const float* vmin)

{
 rectangle(1,1,getmaxx(),getmaxy());
 setcolor(11);
 axay(vmax,vmin);
 axax(linie0,a,b);

//line((int)a/2,(int)fabs(20-y[0]),(int)fabs(a-b),(int)fabs(y[0]-y[1]));
line(20,(int)fabs(20-y[0]),(int)fabs(a-b),(int)fabs(y[0]-y[1]));//Here look
//line((int)a+20,10+(int)fabs(y[0]),(int)b+(int)a,(int)fabs(y[0]-y[1]));
//  line(x1+450,150-y1,x2+450,150-y2);



 for(i=0;i<xmax;i++){
 putpixel(i+20,10+(int)floor(y[i]),15);
// if(((int)y[i]<20)&&((int)y[i+1]>20)) circle(i+20,10+(int)floor(y[i]),30);

}
 outtextxy(20,460,"Alt interval (D)a / (N)u ");

}

/***************************************/
void MeBis(float a, float b,float n){
 float  c;

 for(int i=0;i<n;i++)
 {
  c=(a+b)/2;
  printf("i= %3d \tx= %8.4f \tf(x)= %8.4f \n",i,c,f(c));
   if( f(c)==0) break;
   else if(f(c)*f(a)>0) a=c;
   else b=c;
 }
}

void MeBis_e(float a, float b,float n,float epsilon)
{
 float c;
 while( fabs(b-a) <epsilon)
 {
  c=(b+a)/2;

  printf("x= %8.4f \tf(x)= %8.4f \n",c,f(c));
   if( f(c)==0) break;
   else if(f(c)*f(a)>0) a=c;
   else b=c;
  }
}

/***************************************/

int main()
{ grafica();

 int linie0,n; 
 float y[3000];
 float a,b,vmax,vmin;
 float eps;



while(1)
{
 printf("a= ");
 scanf("%f",&a);
 printf("b= ");
 scanf("%f",&b);

 printf("\nn= ");
 scanf("%d",&n);
 printf("epsilon: ");
 scanf("%f",&eps);

 calcul(a,b,y);
 normare(y,&linie0,&vmax,&vmin);
 grafica();
 modeleazaGrafic(y,linie0,&a,&b,&vmax,&vmin);
 printf("\nApasati p/u a vedea rezultatele: ");
 getch();
 closegraph(); 
 MeBis_e(a,b,n,eps);
 printf("\nDatele Noi\n");

} 

   getch();
   return 0;

}

here is output:http://s30.postimg.org/hmd3oi31p/out.png

but should look like http://s30.postimg.org/wjlkpiga5/image.png (expected)

The images are too small and are unclear when expanded to a reasonable size. Please repost the images at a larger scale.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.