这里写图片描述

数学问题~ 直线和圆交点的判断 就是写公式的时候注意一下 其它部分还好吧~

#include<stdio.h>
#include<math.h>
int main() {
    double x, y, r ,A ,B, C;
    double sum,gen;
    while(scanf("%lf %lf %lf %lf %lf %lf",&x,&y,&r,&A,&B,&C)!=EOF) {
        sum=A*x+B*y+C;
        gen=sqrt(A*A+B*B);
        if(sum<0)
            sum=-sum;
        if((sum/gen)<r)
            printf("2\n");
        else if((sum/gen)>r)
            printf("0\n");
        else
            printf("1\n");
    }
    return 0;
}

题目地址:【郑轻】[1768]Lovely Circular And Linear

© DiDaPiPa all right reserved,powered by GitbookRevision Time: 2020-03-12 21:32:06

results matching ""

    No results matching ""