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;

}

相关推荐
caimouse25 分钟前
ReactOS 图形系统分析(33):字体子系统 — font.c
c语言·开发语言·reactos
cxr82839 分钟前
HyperMind Lab M1 架构地基 Implementation Plan <二>
开发语言·人工智能·架构
灵晔君1 小时前
【Linux】进程控制(一)——进程创建、进程终止与进程等待
linux·c语言·算法
特立独行的猫a1 小时前
Tauri v2的Rust应用 → HarmonyOS(鸿蒙 PC)移植30分钟速成指南
开发语言·rust·harmonyos·tauri·移植·鸿蒙pc
迷迭香yy1 小时前
大宗交易折溢价因子怎么挖掘本地化Python全流程实战
开发语言·人工智能·python
xieliyu.1 小时前
UPD协议结构以及开发中注意事项
java·开发语言·笔记·java-ee
Yweir1 小时前
AI大模型开发-Python介绍、版本说明
开发语言·人工智能·python
峥嵘life9 小时前
Android16 311Y3 EAP-TLS 网络连接失败分析与修复总结
android·开发语言·人工智能·php
mqiqe12 小时前
AgentScope Java Harness:4. 双层记忆系统 让 Agent 拥有真正的“长期大脑“
java·开发语言
gugucoding12 小时前
46. 【Java】JUC并发工具:让并发更简单
java·开发语言