当前位置: 首页 > news >正文

C++练习1

#include <stdio.h>struct complex{int real;int imag;
};//结构体定义:分为实部和虚部struct complex multiply(struct complex x, struct complex y);
//函数声明
int main()
{struct complex product, x, y;scanf("%d%d%d%d", &x.real, &x.imag, &y.real, &y.imag);//输入俩实部和虚部product = multiply(x, y);//使用函数返回复数计算的结果printf("(%d+%di) * (%d+%di) = %d + %di\n", x.real, x.imag, y.real, y.imag, product.real, product.imag);return 0;
}struct complex multiply(struct complex x, struct complex y){struct complex res;res.real=x.real*y.real-x.imag*y.imag;res.imag=x.real*y.imag+x.imag*y.real;return res;
}
#include <stdio.h>
#include <math.h>struct point {double x, y, z;
};void read_point(struct point *p);
double distance(struct point a, struct point b);int main(void)
{struct point p1, p2;read_point(&p1);read_point(&p2);printf("%f\n", distance(p1, p2));return 0;
}void read_point(struct point *p)
{scanf("%lf %lf %lf", &p->x, &p->y, &p->z);
}//  计算并返回平面上两点 a 和 b 之间的欧氏距离
double distance(struct point a, struct point b){double res;res=pow((a.x-b.x),2)+pow((a.y-b.y),2)+pow((a.z-b.z),2);res=sqrt(res);return res;
}

 

http://www.jsqmd.com/news/29420/

相关文章:

  • 2025.11.2总结
  • claude_code_clone
  • 第二届数证杯初赛-计算机取证
  • 视频瘦身大师
  • 如何把应用程序的图标都摆在xfce的panel上
  • 读《纳瓦尔宝典》之判断力:一
  • 团队作业
  • 每日反思(2025_11_02)
  • 修仙类(基类,派生类)
  • 第二章数字的表示和运算
  • 利用XPlaneConnect从X-Plane内读写数据
  • fastdbchkrep项目(数据库自动生成巡检报告) open source
  • cf2000左右dp
  • nginx入门-server基础
  • Typora使用命令
  • 免费智普大模型调用
  • 嵌入式C语言寄存器操作
  • ubuntu使用命令
  • PC 指针为何不等于执行地址?
  • VIM使用教程
  • 【Shell脚本】 目录清理脚本
  • 第一次团队作业
  • 题解:CF1975E Chain Queries
  • 题解:P4895 独钓寒江雪
  • 题解:P7201 [COCI 2019/2020 #1] Džumbus
  • 题解:CF913D Too Easy Problems
  • 题解:CF875C National Property
  • 题解:CF1037E Trips
  • lecms在使用redis中设置他缓存时间
  • 题解:CF387E George and Cards