편집 기록

편집 기록
  • 프로필 nowp님의 편집
    날짜2022.05.26

    Why distance of two point is -nan(ind)??


    #include <stdio.h>
    #include <math.h>
    #pragma warning(disable:4996)
    
    #define PI 3.14
    
    typedef struct point
    {
        int xpos;
        int ypos;   
    } Point;
    
    typedef struct circle
    {
        Point cen;
        int rad;   
    } Circle;
    
    Circle GetCircleInfo(void)
    {
        Circle Cen, Rad;
        printf("Input focus and radius of circle: ");
        scanf("%d %d %d", &Cen.cen.xpos, &Cen.cen.ypos, &Rad.rad);
        return Cen, Rad;    
    }
    
    void CalcCircle(Circle *c1, Circle *c2)
    {
        double distance;
        double area1, area2;
    
        distance = sqrt((double)((c1->cen.xpos - c2->cen.xpos) * (c1->cen.xpos - c2->cen.xpos) + (c1->cen.ypos - c2->cen.ypos) * (c1->cen.ypos - c2->cen.ypos)));
        area1 = (double)( (c1->rad) * (c1->rad) * PI );
        area2 = (double)( (c2->rad) * (c2->rad) * PI );
    
        printf("Distance of two point is %g \n", distance);
        printf("Area of C1 is %g \n", area1);
        printf("Area of C2 is %g \n", area2);   
    }
    
    int main(void)
    {
        Circle C1 = GetCircleInfo();
        Circle C2 = GetCircleInfo();
    
        CalcCircle(&C1, &C2);
    
        return 0;
    }
    
    
  • 프로필 알 수 없는 사용자님의 편집
    날짜2016.11.17

    Why distance of two point is -nan(ind)??


    #include <stdio.h>

    #include <math.h>

    #pragma warning(disable:4996)

    #define PI 3.14

    typedef struct point {

    int xpos;
    int ypos;
    

    } Point;

    typedef struct circle {

    Point cen;
    int rad;
    

    } Circle;

    Circle GetCircleInfo(void) {

    Circle Cen, Rad;
    printf("Input focus and radius of circle: ");
    scanf("%d %d %d", &Cen.cen.xpos, &Cen.cen.ypos, &Rad.rad);
    return Cen, Rad;
    

    }

    void CalcCircle(Circle *c1, Circle *c2) {

    double distance;
    double area1, area2;
    
    distance = sqrt((double)((c1->cen.xpos - c2->cen.xpos) * (c1->cen.xpos - c2->cen.xpos) + (c1->cen.ypos - c2->cen.ypos) * (c1->cen.ypos - c2->cen.ypos)));
    area1 = (double)( (c1->rad) * (c1->rad) * PI );
    area2 = (double)( (c2->rad) * (c2->rad) * PI );
    
    printf("Distance of two point is %g \n", distance);
    printf("Area of C1 is %g \n", area1);
    printf("Area of C2 is %g \n", area2);
    

    }

    int main(void) {

    Circle C1 = GetCircleInfo();
    Circle C2 = GetCircleInfo();
    
    CalcCircle(&C1, &C2);
    
    return 0;
    

    }