===========================================================================
CODING
#include<all.h>
void main()
{
mon();
int medx,medy,x,y,i,j,A,B,C,A1,B1,C1,A2,B2,C2,x1,x2,y1,y2,x3,y3,a1,a2,b1,b2,c1,c2,Rx,Ry,largex,largey,minx,miny;
float Area;
clrscr();
cout<<" (A*x)+(B*y)+C=0\n\n Enter:-\n A= ";
cin>>A;
cout<<" B= ";
cin>>B;
cout<<" C= ";
cin>>C;
cout<<"\n\n";
cout<<" (X*x)+(Y*y)+Z=0\n\n Enter:-\n X= ";
cin>>A1;
cout<<" Y= ";
cin>>B1;
cout<<" Z= ";
cin>>C1;
cout<<"\n\n";
cout<<" (P*x)+(Q*y)+R=0\n\n Enter:-\n P= ";
cin>>A2;
cout<<" Q= ";
cin>>B2;
cout<<" R= ";
cin>>C2;
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 && B==0 && C==0)
{
for(j=-10;j<=10;j++)
{
i=0;
if(i>=-10 && i<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
for(i=-10;i<=10;i++)
{
j=0;
if(j>=-10 && j<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
}
else if(B!=0)
{
for(i=-10;i<=10;i++)
{
j=-(i*A+C)/B;
if(j>=-10 && j<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
}
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);
}
}
}
textcolor(12+BLINK);
if(A1==0 && B1==0 && C1==0)
{
for(j=-10;j<=10;j++)
{
i=0;
if(i>=-10 && i<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
for(i=-10;i<=10;i++)
{
j=0;
if(j>=-10 && j<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
}
else if(B1!=0)
{
for(i=-10;i<=10;i++)
{
j=-(i*A1+C1)/B1;
if(j>=-10 && j<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
}
else
{
for(j=-10;j<=10;j++)
{
i=-C1/A1;
if(i>=-10 && i<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
}
textcolor(YELLOW+BLINK);
if(A2==0 && B2==0 && C2==0)
{
for(j=-10;j<=10;j++)
{
i=0;
if(i>=-10 && i<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
for(i=-10;i<=10;i++)
{
j=0;
if(j>=-10 && j<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
}
else if(B2!=0)
{
for(i=-10;i<=10;i++)
{
j=-(i*A2+C2)/B2;
if(j>=-10 && j<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
}
else
{
for(j=-10;j<=10;j++)
{
i=-C2/A2;
if(i>=-10 && i<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
}
if(A==0)
{
y1=-C/B;
x1=(-C1-B1*y1)/A1;
}
else if(A1==0)
{
y1=-C1/B1;
x1=(-C-B*y1)/A;
}
else if(B==0)
{
x1=-C/A;
y1=(-C1-A1*x1)/B1;
}
else if(B1==0)
{
x1=-C1/A1;
y1=(-C-A*x1)/B;
}
else
{
a1=A1*A;
b1=A1*B;
c1=A1*C;
a2=A*A1;
b2=A*B1;
c2=A*C1;
if(b1-b2==0)
y1=0;
else
y1=(c2-c1)/(b1-b2);
b1=b1*y1;
if(a1==0)
x1=0;
else
x1=(-c1-b1)/a1;
}
if(A1==0)
{
y2=-C1/B1;
x2=(-C2-B2*y1)/A2;
}
else if(A2==0)
{
y2=-C2/B2;
x2=(-C1-B1*y1)/A1;
}
else if(B==0)
{
x2=-C1/A1;
y2=(-C2-A2*x1)/B2;
}
else if(B2==0)
{
x2=-C2/A2;
y2=(-C1-A1*x1)/B1;
}
else
{
a1=A2*A1;
b1=A2*B1;
c1=A2*C1;
a2=A1*A2;
b2=A1*B2;
c2=A1*C2;
if(b1-b2==0)
y2=0;
else
y2=(c2-c1)/(b1-b2);
b1=b1*y2;
if(a1==0)
x2=0;
else
x2=(-c1-b1)/a1;
}
if(A==0)
{
y3=-C/B;
x3=(-C2-B2*y3)/A2;
}
else if(A2==0)
{
y3=-C2/B2;
x3=(-C-B*y3)/A;
}
else if(B==0)
{
x3=-C/A;
y3=(-C2-A2*x3)/B2;
}
else if(B2==0)
{
x3=-C2/A2;
y3=(-C-A*x3)/B;
}
else
{
a1=A2*A;
b1=A2*B;
c1=A2*C;
a2=A*A2;
b2=A*B2;
c2=A*C2;
if(b1-b2==0)
y3=0;
else
y3=(c2-c1)/(b1-b2);
b1=b1*y3;
if(a1==0)
x3=0;
else
x3=(-c1-b1)/a1;
}
gotoxy(1,1);
/* textcolor(WHITE);
gotoxy(41+3*x1,12-y1);
cprintf("■");
gotoxy(41+3*x2,12-y2);
cprintf("■");
gotoxy(41+3*x3,12-y3);
cprintf("■"); */
Area=fabs(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))/2.0;
largex=x1>x2?(x1>x3?x1:x2):(x2>x3?x2:x3);
largey=y1>y2?(y1>y3?y1:y2):(y2>y3?y2:y3);
minx=x1<x2?(x1<x3?x1:x3):(x2<x3?x2:x3);
miny=y1<y2?(y1<y3?y1:y3):(y2<y3?y2:y3);
// medx=x1==largex?(x2==minx?x3:x2):(x2==minx?x1:(x3==minx?x1:x2==largex?x3:x2));
// medy=y1==largey?(y2==miny?y3:y2):(y2==miny?y1:(y3==miny?y1:y2==largey?y3:y2));
textcolor(5);
if(A==0 && B==0 && C==0)
{
for(j=minx;j<=largey;j++)
{
i=0;
if(i>=minx && i<=largex)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
for(i=minx;i<=largex;i++)
{
j=0;
if(j>=miny && j<=largey)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
}
else if(B!=0)
{
for(i=minx;i<=largex;i++)
{
j=-(i*A+C)/B;
if(j>=miny && j<=largey)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
}
else
{
for(j=miny;j<=largey;j++)
{
i=-C/A;
if(i>=minx && i<=largex)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
}
if(A1==0 && B1==0 && C1==0)
{
for(j=miny;j<=largey;j++)
{
i=0;
if(i>=minx && i<=largex)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
for(i=minx;i<=largex;i++)
{
j=0;
if(j>=miny && j<=largey)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
}
else if(B1!=0)
{
for(i=minx;i<=largex;i++)
{
j=-(i*A1+C1)/B1;
if(j>=miny && j<=largey)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
}
else
{
for(j=miny;j<=largey;j++)
{
i=-C1/A1;
if(i>=minx && i<=largex)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
}
if(A2==0 && B2==0 && C2==0)
{
for(j=miny;j<=largey;j++)
{
i=0;
if(i>=minx && i<=largex)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
for(i=minx;i<=largex;i++)
{
j=0;
if(j>=miny && j<=largey)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
}
else if(B2!=0)
{
for(i=minx;i<=largex;i++)
{
j=-(i*A2+C2)/B2;
if(j>=miny && j<=largey)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
}
else
{
for(j=miny;j<=largey;j++)
{
i=-C2/A2;
if(i>=minx && i<=largex)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
}
gotoxy(35,24);
textcolor(WHITE);
cprintf("Area of Region: %.2f",Area);
getch();
}
CODING
#include<all.h>
void main()
{
mon();
int medx,medy,x,y,i,j,A,B,C,A1,B1,C1,A2,B2,C2,x1,x2,y1,y2,x3,y3,a1,a2,b1,b2,c1,c2,Rx,Ry,largex,largey,minx,miny;
float Area;
clrscr();
cout<<" (A*x)+(B*y)+C=0\n\n Enter:-\n A= ";
cin>>A;
cout<<" B= ";
cin>>B;
cout<<" C= ";
cin>>C;
cout<<"\n\n";
cout<<" (X*x)+(Y*y)+Z=0\n\n Enter:-\n X= ";
cin>>A1;
cout<<" Y= ";
cin>>B1;
cout<<" Z= ";
cin>>C1;
cout<<"\n\n";
cout<<" (P*x)+(Q*y)+R=0\n\n Enter:-\n P= ";
cin>>A2;
cout<<" Q= ";
cin>>B2;
cout<<" R= ";
cin>>C2;
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 && B==0 && C==0)
{
for(j=-10;j<=10;j++)
{
i=0;
if(i>=-10 && i<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
for(i=-10;i<=10;i++)
{
j=0;
if(j>=-10 && j<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
}
else if(B!=0)
{
for(i=-10;i<=10;i++)
{
j=-(i*A+C)/B;
if(j>=-10 && j<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
}
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);
}
}
}
textcolor(12+BLINK);
if(A1==0 && B1==0 && C1==0)
{
for(j=-10;j<=10;j++)
{
i=0;
if(i>=-10 && i<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
for(i=-10;i<=10;i++)
{
j=0;
if(j>=-10 && j<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
}
else if(B1!=0)
{
for(i=-10;i<=10;i++)
{
j=-(i*A1+C1)/B1;
if(j>=-10 && j<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
}
else
{
for(j=-10;j<=10;j++)
{
i=-C1/A1;
if(i>=-10 && i<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
}
textcolor(YELLOW+BLINK);
if(A2==0 && B2==0 && C2==0)
{
for(j=-10;j<=10;j++)
{
i=0;
if(i>=-10 && i<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
for(i=-10;i<=10;i++)
{
j=0;
if(j>=-10 && j<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
}
else if(B2!=0)
{
for(i=-10;i<=10;i++)
{
j=-(i*A2+C2)/B2;
if(j>=-10 && j<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
}
else
{
for(j=-10;j<=10;j++)
{
i=-C2/A2;
if(i>=-10 && i<=10)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
delay(200);
}
}
}
if(A==0)
{
y1=-C/B;
x1=(-C1-B1*y1)/A1;
}
else if(A1==0)
{
y1=-C1/B1;
x1=(-C-B*y1)/A;
}
else if(B==0)
{
x1=-C/A;
y1=(-C1-A1*x1)/B1;
}
else if(B1==0)
{
x1=-C1/A1;
y1=(-C-A*x1)/B;
}
else
{
a1=A1*A;
b1=A1*B;
c1=A1*C;
a2=A*A1;
b2=A*B1;
c2=A*C1;
if(b1-b2==0)
y1=0;
else
y1=(c2-c1)/(b1-b2);
b1=b1*y1;
if(a1==0)
x1=0;
else
x1=(-c1-b1)/a1;
}
if(A1==0)
{
y2=-C1/B1;
x2=(-C2-B2*y1)/A2;
}
else if(A2==0)
{
y2=-C2/B2;
x2=(-C1-B1*y1)/A1;
}
else if(B==0)
{
x2=-C1/A1;
y2=(-C2-A2*x1)/B2;
}
else if(B2==0)
{
x2=-C2/A2;
y2=(-C1-A1*x1)/B1;
}
else
{
a1=A2*A1;
b1=A2*B1;
c1=A2*C1;
a2=A1*A2;
b2=A1*B2;
c2=A1*C2;
if(b1-b2==0)
y2=0;
else
y2=(c2-c1)/(b1-b2);
b1=b1*y2;
if(a1==0)
x2=0;
else
x2=(-c1-b1)/a1;
}
if(A==0)
{
y3=-C/B;
x3=(-C2-B2*y3)/A2;
}
else if(A2==0)
{
y3=-C2/B2;
x3=(-C-B*y3)/A;
}
else if(B==0)
{
x3=-C/A;
y3=(-C2-A2*x3)/B2;
}
else if(B2==0)
{
x3=-C2/A2;
y3=(-C-A*x3)/B;
}
else
{
a1=A2*A;
b1=A2*B;
c1=A2*C;
a2=A*A2;
b2=A*B2;
c2=A*C2;
if(b1-b2==0)
y3=0;
else
y3=(c2-c1)/(b1-b2);
b1=b1*y3;
if(a1==0)
x3=0;
else
x3=(-c1-b1)/a1;
}
gotoxy(1,1);
/* textcolor(WHITE);
gotoxy(41+3*x1,12-y1);
cprintf("■");
gotoxy(41+3*x2,12-y2);
cprintf("■");
gotoxy(41+3*x3,12-y3);
cprintf("■"); */
Area=fabs(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))/2.0;
largex=x1>x2?(x1>x3?x1:x2):(x2>x3?x2:x3);
largey=y1>y2?(y1>y3?y1:y2):(y2>y3?y2:y3);
minx=x1<x2?(x1<x3?x1:x3):(x2<x3?x2:x3);
miny=y1<y2?(y1<y3?y1:y3):(y2<y3?y2:y3);
// medx=x1==largex?(x2==minx?x3:x2):(x2==minx?x1:(x3==minx?x1:x2==largex?x3:x2));
// medy=y1==largey?(y2==miny?y3:y2):(y2==miny?y1:(y3==miny?y1:y2==largey?y3:y2));
textcolor(5);
if(A==0 && B==0 && C==0)
{
for(j=minx;j<=largey;j++)
{
i=0;
if(i>=minx && i<=largex)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
for(i=minx;i<=largex;i++)
{
j=0;
if(j>=miny && j<=largey)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
}
else if(B!=0)
{
for(i=minx;i<=largex;i++)
{
j=-(i*A+C)/B;
if(j>=miny && j<=largey)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
}
else
{
for(j=miny;j<=largey;j++)
{
i=-C/A;
if(i>=minx && i<=largex)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
}
if(A1==0 && B1==0 && C1==0)
{
for(j=miny;j<=largey;j++)
{
i=0;
if(i>=minx && i<=largex)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
for(i=minx;i<=largex;i++)
{
j=0;
if(j>=miny && j<=largey)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
}
else if(B1!=0)
{
for(i=minx;i<=largex;i++)
{
j=-(i*A1+C1)/B1;
if(j>=miny && j<=largey)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
}
else
{
for(j=miny;j<=largey;j++)
{
i=-C1/A1;
if(i>=minx && i<=largex)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
}
if(A2==0 && B2==0 && C2==0)
{
for(j=miny;j<=largey;j++)
{
i=0;
if(i>=minx && i<=largex)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
for(i=minx;i<=largex;i++)
{
j=0;
if(j>=miny && j<=largey)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
}
else if(B2!=0)
{
for(i=minx;i<=largex;i++)
{
j=-(i*A2+C2)/B2;
if(j>=miny && j<=largey)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
}
else
{
for(j=miny;j<=largey;j++)
{
i=-C2/A2;
if(i>=minx && i<=largex)
{
y=12-j;
x=41+3*i;
gotoxy(x,y);
cprintf("■");
}
}
}
gotoxy(35,24);
textcolor(WHITE);
cprintf("Area of Region: %.2f",Area);
getch();
}
===========================================================================
No comments:
Post a Comment