重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
#include stdio.h
成都创新互联长期为千余家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为湖南企业提供专业的做网站、网站制作,湖南网站改版等技术服务。拥有十年丰富建站经验和众多成功案例,为您定制开发。
struct complex
{
int re;
int im;
};
void add(struct complex a, struct complex b, struct complex *c)
{
c-re=a.re+b.re;
c-im=a.im+b.im;
}
void minus(struct complex a, struct complex b, struct complex *c)
{
c-re=a.re-b.re;
c-im=a.im-b.im;
}
int main()
{
struct complex x,y,s,p;
scanf("%d%d",x.re,x.im);
scanf("%d%d",y.re,y.im);
add(x,y,s);
printf(" sum=%5d+%5di\n",s.re,s.im);
minus(x,y,p);
printf(" product=%5d+%5di\n",p.re,p.im);
return 0;
}
#includestdio.h
double jia(double a,double b){
return a+b;}
double jian(double a,double b){
return a-b;}
double cheng(double a,double b){
return a*b;}
double chu(double a,double b){
return a/b;}
int modd(int a,int b){
return a%b;}
int main(){
double a,b;
printf("输入两个数字\n");
scanf("%lf%lf",a,b);
printf("加 %lf\n减 %lf\n乘 %lf\n除 %lf\n取模 %d\n",jia(a,b),jian(a,b),cheng(a,b),chu(a,b),modd((int)a,(int)b));
return 0;}
# includestdio.h
double jia(double x, double d)
{
double s;
s = x+d;
return s;
}
double jian(double x, double d)
{
double s;
s = x-d;
return s;
}
double cheng(double x, double d)
{
double s;
s = x*d;
return s;
}
double chu(double x, double d)
{
double s;
s = x/d;
return s;
}
int main(void)
{
double i, j, k;
char t;
k = 0;
printf("请输入要计算什么运算“+”“-”“*”“/”\n");
scanf("%c", t);
if(t == '+')
{
printf("请输入要相加的两个数\n");
scanf("%lf %lf", i, j);
k = jia(i, j);
printf("这两个数相加为%6.2lf\n", k);
}
else if(t == '-')
{
printf("请输入要相减的两个数\n");
scanf("%lf %lf", i, j);
k = jian(i, j);
printf("这两个数相减为%6.2lf\n", k);
}
else if(t == '*')
{
printf("请输入要相*的两个数\n");
scanf("%lf %lf", i, j);
k = cheng(i, j);
printf("这两个数相*为%6.2lf\n", k);
}
else if(t == '/')
{
printf("请输入要相/的两个数\n");
scanf("%lf %lf", i, j);
k = chu(i, j);
printf("这两个数相/为%6.2lf\n", k);
}
else
{
printf("对不起目前只支持“+”“-”“*”“/”\n");
}
return 0;
}