Chimed

Ялгавар
batchunag

Хаалтыг сэргээх
lmo_0731

Холимог сэлгэмэл
batchunag

Тоон куб
Irmuun
Энд дарж татаж авна уу.
#include "iostream.h"
#include "math.h"
int ax, ay, bx, by, cx, cy;
double ox, oy, r;
double upper, lower, right, left;
int iUpper, iLower, iRight, iLeft;
void circle(){
int a2=ax*ax+ay*ay, b2=bx*bx+by*by, c2=cx*cx+cy*cy;
int up=(a2-b2)*(bx-cx)-(b2-c2)*(ax-bx);
int down=(ay-by)*(bx-cx)+(ax-bx)*(cy-by);
oy=(1.0/2*up)/down;
up=(a2-c2)*(by-cy)-(b2-c2)*(ay-cy);
down=(ax-cx)*(by-cy)+(ay-cy)*(cx-bx);
ox=(1.0/2*up)/down;
r=sqrt((ax-ox)*(ax-ox)+(ay-oy)*(ay-oy));
}//finds values for r, ox, oy
void limits(){
upper=oy+r;
lower=oy-r;
right=ox+r;
left=ox-r;
}//sets values to variables upper, lower, right, left
double line(double x, double y){
return (x-ax)*(cy-ay)-(y-ay)*(cx-ax);
}
int on(double x, double y){
if(line(x, y)*line(bx, by)<0)
return 0;
else return 1;
}//returns 1 if point (x, y) on the arc, or 0
main(){
cin>>ax>>ay>>cx>>cy>>bx>>by;
circle();
limits();
if(on(ox, upper)!=1){
iUpper=ay;
if(iUpper iUpper=cy;
}
else{
iUpper=int(floor(upper));
if(upper-iUpper>0.0000001)
iUpper++;
}
if(on(ox, lower)!=1){
iLower=ay;
if(iLower>cy)
iLower=cy;
}
else{
iLower=int(floor(lower));
}
if(on(left, oy)!=1){
iLeft=ax;
if(iLeft>cx)
iLeft=cx;
}
else{
iLeft=int(floor(left));
}
if(on(right, oy)!=1){
iRight=ax;
if(iRight iRight=cx;
}
else{
iRight=int(floor(right));
if(right-iRight>0.0000001)
iRight++;
}
cout<<(iUpper-iLower)*(iRight-iLeft);
return 0;
}