===========================================================================
CODING
#include<all.h>
void main()
{
int vertex,x,y,i,j,A,B,C,i1,i2;
float D;
clrscr();
first();
second();
first();
cprintf(" y=A*xý+B*x+C\r\n\r\n Enter:-\r\n A= ");
cscanf("%d",&A);
cprintf("\r\n B= ");
cscanf("%d",&B);
cprintf("\r\n C= ");
cscanf("%d",&C);
clrscr();
for(i=-11,x=7,y=12;i<=11;x=x+3,i++)
{
if(i==-11)
{
gotoxy(x+2,y);
cprintf("®");
}
else if(i==11)
{
gotoxy(x,y);
cprintf("¯");
}
else
{
gotoxy(x,y);
cprintf("ÄÂÄ");
gotoxy(x,y+1);
if(i==0);
else if(i>0 && i<10)
cprintf(" %d",i);
else
cprintf("%d",i);
}
}
for(i=11,x=39,y=1;i>=-11;i--,y++)
{
gotoxy(x,y);
if(i==-11)
cprintf(" ");
else if(i==11)
cprintf(" ");
else
{
if(i==0)
cprintf("");
else if(i>0 && i<10)
cprintf(" %d",i);
else if(i==-10)
cprintf("\b%d",i);
else
cprintf("%d",i);
gotoxy(x+2,y);
if(i==0)
cprintf("Å");
else
cprintf("´");
}
}
textcolor(10+BLINK);
if(A==0)
{
for(i=-10;i<=10;i++)
{
j=(i*B+C);
if(j>=-10 && j<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("þ");
delay(200);
}
}
}
else
{
// if(B!=0)
// {
/*for(y=-10;y<=10;y++)
0=a*xý+b*x+(c-y)
D=b*b-4*a*(c-y);
x=-b+sqrt( */
vertex=-B*B/(4*A)+C;
if(A>=0)
{
for(j=vertex;j<=10;j++)
{
D=sqrt(B*B-4*A*(C-j));
if(D==(int)D)
{
i1=(-B+D)/(2*A);
i2=(-B-D)/(2*A);
if(i2>=-10 && i2<=10)
{
y=12-j;
x=41+3*i2;
gotoxy(x,y);
cprintf("þ");
}
if(i1>=-10 && i1<=10)
{
y=12-j;
x=41+3*i1;
gotoxy(x,y);
cprintf("þ");
delay(500);
}
}
}
}
else
{
for(j=-10;j<=vertex;j++)
{
D=sqrt(B*B-4*A*(C-j));
if(D==(int)D)
{
i1=(-B+D)/(2*A);
i2=(-B-D)/(2*A);
if(i2>=-10 && i2<=10)
{
y=12-j;
x=41+3*i2;
gotoxy(x,y);
cprintf("þ");
}
if(i1>=-10 && i1<=10)
{
y=12-j;
x=41+3*i1;
gotoxy(x,y);
cprintf("þ");
delay(500);
}
}
}
}
// }
/* else
{
for(j=-10;j<=10;j++)
{
i=-C/A;
if(i>=-10 && i<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("þ");
delay(200);
}
}
} */
}
getch();
getch();
}
CODING
#include<all.h>
void main()
{
int vertex,x,y,i,j,A,B,C,i1,i2;
float D;
clrscr();
first();
second();
first();
cprintf(" y=A*xý+B*x+C\r\n\r\n Enter:-\r\n A= ");
cscanf("%d",&A);
cprintf("\r\n B= ");
cscanf("%d",&B);
cprintf("\r\n C= ");
cscanf("%d",&C);
clrscr();
for(i=-11,x=7,y=12;i<=11;x=x+3,i++)
{
if(i==-11)
{
gotoxy(x+2,y);
cprintf("®");
}
else if(i==11)
{
gotoxy(x,y);
cprintf("¯");
}
else
{
gotoxy(x,y);
cprintf("ÄÂÄ");
gotoxy(x,y+1);
if(i==0);
else if(i>0 && i<10)
cprintf(" %d",i);
else
cprintf("%d",i);
}
}
for(i=11,x=39,y=1;i>=-11;i--,y++)
{
gotoxy(x,y);
if(i==-11)
cprintf(" ");
else if(i==11)
cprintf(" ");
else
{
if(i==0)
cprintf("");
else if(i>0 && i<10)
cprintf(" %d",i);
else if(i==-10)
cprintf("\b%d",i);
else
cprintf("%d",i);
gotoxy(x+2,y);
if(i==0)
cprintf("Å");
else
cprintf("´");
}
}
textcolor(10+BLINK);
if(A==0)
{
for(i=-10;i<=10;i++)
{
j=(i*B+C);
if(j>=-10 && j<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("þ");
delay(200);
}
}
}
else
{
// if(B!=0)
// {
/*for(y=-10;y<=10;y++)
0=a*xý+b*x+(c-y)
D=b*b-4*a*(c-y);
x=-b+sqrt( */
vertex=-B*B/(4*A)+C;
if(A>=0)
{
for(j=vertex;j<=10;j++)
{
D=sqrt(B*B-4*A*(C-j));
if(D==(int)D)
{
i1=(-B+D)/(2*A);
i2=(-B-D)/(2*A);
if(i2>=-10 && i2<=10)
{
y=12-j;
x=41+3*i2;
gotoxy(x,y);
cprintf("þ");
}
if(i1>=-10 && i1<=10)
{
y=12-j;
x=41+3*i1;
gotoxy(x,y);
cprintf("þ");
delay(500);
}
}
}
}
else
{
for(j=-10;j<=vertex;j++)
{
D=sqrt(B*B-4*A*(C-j));
if(D==(int)D)
{
i1=(-B+D)/(2*A);
i2=(-B-D)/(2*A);
if(i2>=-10 && i2<=10)
{
y=12-j;
x=41+3*i2;
gotoxy(x,y);
cprintf("þ");
}
if(i1>=-10 && i1<=10)
{
y=12-j;
x=41+3*i1;
gotoxy(x,y);
cprintf("þ");
delay(500);
}
}
}
}
// }
/* else
{
for(j=-10;j<=10;j++)
{
i=-C/A;
if(i>=-10 && i<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("þ");
delay(200);
}
}
} */
}
getch();
getch();
}
===========================================================================
No comments:
Post a Comment