如题所述
第1个回答 2014-05-07
给你一个做加法的示例:
#include <stdio.h>
/*定义复数结构体*/
typedef struct
{
double real; /*复数的实部*/
double image; /*复数的虚部*/
}complex;
/*实现复数加法*/
complex add(complex c1,complex c2)
{
complex res;
res.real=c1.real+c2.real;
res.image=c1.image+c2.image;
return res;
}
/*测试*/
int main()
{
complex c1,c2;
c1.real=1;
c1.image=2;
c2.real=3;
c2.image=4;
complex sum=add(c1,c2);
printf("the sum of c1 and c2 is ( %f,%f )\n",sum.real,sum.image);
return 0;
}本回答被提问者和网友采纳
#include <stdio.h>
/*定义复数结构体*/
typedef struct
{
double real; /*复数的实部*/
double image; /*复数的虚部*/
}complex;
/*实现复数加法*/
complex add(complex c1,complex c2)
{
complex res;
res.real=c1.real+c2.real;
res.image=c1.image+c2.image;
return res;
}
/*测试*/
int main()
{
complex c1,c2;
c1.real=1;
c1.image=2;
c2.real=3;
c2.image=4;
complex sum=add(c1,c2);
printf("the sum of c1 and c2 is ( %f,%f )\n",sum.real,sum.image);
return 0;
}本回答被提问者和网友采纳
第2个回答 2014-05-07
c语言的
内部的应用的要
内部的应用的要