C Primer Plus(第六版)16.18 编程练习 第3题

#include <stdio.h>

#include <math.h>

#define PI 3.14159265358979

struct j{

double len;

double jd;

};

struct z{

double x;

double y;

};

struct z jtoz(struct j pj);

int main(void)

{

double hd;

struct j pj = {

sqrt(2.0),//根号2,45度的边长是1

45.0,

};

struct z zj;

zj=jtoz(pj);

printf("x=%lf y=%lf\n",zj.x,zj.y);

}

struct z jtoz(struct j pj)

{

struct z zj;

double hd;

hd=pj.jd*PI/180.0;

zj.x = pj.len * cos(hd);

zj.y = pj.len * sin(hd);

return zj;

}

相关推荐
FuckPatience1 小时前
Visual Studio C# 项目中文件后缀简介
开发语言·c#
014-code8 小时前
订单超时取消与库存回滚的完整实现(延迟任务 + 状态机)
java·开发语言
lly2024068 小时前
组合模式(Composite Pattern)
开发语言
游乐码8 小时前
c#泛型约束
开发语言·c#
Dontla8 小时前
go语言Windows安装教程(安装go安装Golang安装)(GOPATH、Go Modules)
开发语言·windows·golang
chushiyunen8 小时前
python rest请求、requests
开发语言·python
铁东博客9 小时前
Go实现周易大衍筮法三变取爻
开发语言·后端·golang
baidu_huihui9 小时前
在 CentOS 9 上安装 pip(Python 的包管理工具)
开发语言·python·pip
南 阳9 小时前
Python从入门到精通day63
开发语言·python
lbb 小魔仙9 小时前
Python_RAG知识库问答系统实战指南
开发语言·python