标题:结构体作为形参的简单程序,关于复数的计算,函数哪里有问题?
取消只看楼主
大学新生007
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2017-3-22
结帖率:0
已结贴  问题点数:20 回复次数:0 
结构体作为形参的简单程序,关于复数的计算,函数哪里有问题?
#include<stdio.h>
struct mycomplex
{
    double real;
    double image;
};
struct mycomplex input(void)
struct mycomplex add(struct mycomplex c1,struct mycomplex c2)
struct mycomplex mul(struct mycomplex c1,struct mycomplex c2)
void output(struct mycomplex c1)
int main(void)
{
 struct mycomplex a,b,c,d;
 a=input();
 b=input();
 c=add(a,b);
 d=mul(a,b);
 output(c);
 output(d);
 return 0;
}
struct mycomplex input(void)
{
  struct mycomplex c1;
    scanf("%lf",&c1.real);
    scanf("%lf",&c1.image);
    return c1;
}
struct mycomplex add(struct mycomplex c1,struct mycomplex c2)
{
    mycomplex c;
    c.real=c1.real+c2.real;
        c.image=c1.image+c2.image;
        return c;
}
struct mycomplex mul(struct mycomplex c1,struct mycomplex c2)
{
    mycomplex d;
    d.real=(c1.real*b.real)+(c2.image*a.image);
    d.image=(c1.real*b.image)+(c2.image*b.real);
    return d;
}
void output(struct mycomplex c1)
{
    printf("%lf+%lf*i",c1.real,c1.image);
}
搜索更多相关主题的帖子: include double return 结构体 
2017-03-22 15:41



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-475372-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.153080 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved