편집 기록

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

    복소수 구조체 구현 중 질문입니다! c2039오류


    #include<stdio.h>
    #include<math.h>
    
    struct complex
    {
        double real;
        double imag;
    };
    
    void add(struct complex* p, struct complex* q, struct complex* r);
    void multiply(struct complex* p, struct complex* q, struct complex* r);
    int main()
    {
        struct complex p;
        struct complex q;
        struct complex r;
        scanf("%lf %lf", p.real, p.imag);
        scanf("%lf %lf", q.real, q.imag);
        add(&p, &q, &r);
        multiply(&p, &q, &r);
    }
    
    void add(struct complex* p, struct complex* q, struct complex* r)
    {
        r->real = p->real + q->real;
        r->imag = p->imag + q->imag;
        printf("%lf %lf", r->real, r->imag);
    }
    
    void multiply(struct complex* p, struct complex* q, struct complex* r)
    {
        r->real = ((p->real) * (q->real)) - ((p->imag) * (q->imag));
        r->imag = ((p->real) * (q->imag)) - ((p->imag) * (q->real));
        printf("%lf %lf", r->real, r->imag);
    }
    
    

    복소수 합, 곱 구하는 문제인데 c2039오류 라면서 맴버가 아니라고 실행이 안되는데 왜 그런건가요?

    감사합니다!

  • 프로필 알 수 없는 사용자님의 편집
    날짜2021.05.17

    구조체 질문입니다!


    #include<stdio.h>
    #include<math.h>
    
    struct complex
    {
        double real;
        double imag;
    };
    
    void add(struct complex* p, struct complex* q, struct complex* r);
    void multiply(struct complex* p, struct complex* q, struct complex* r);
    int main()
    {
        struct complex p;
        struct complex q;
        struct complex r;
        scanf("%lf %lf", p.real, p.imag);
        scanf("%lf %lf", q.real, q.imag);
        add(&p, &q, &r);
        multiply(&p, &q, &r);
    }
    
    void add(struct complex* p, struct complex* q, struct complex* r)
    {
        r->real = p->real + q->real;
        r->imag = p->imag + q->imag;
        printf("%lf %lf", r->real, r->imag);
    }
    
    void multiply(struct complex* p, struct complex* q, struct complex* r)
    {
        r->real = ((p->real) * (q->real)) - ((p->imag) * (q->imag));
        r->imag = ((p->real) * (q->imag)) - ((p->imag) * (q->real));
        printf("%lf %lf", r->real, r->imag);
    }
    
    

    복소수 합, 곱 구하는 문제인데 c2039오류 라면서 맴버가 아니라고 실행이 안되는데 왜 그런건가요??

    감사합니다..!!