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;

}

相关推荐
aaaameliaaa4 小时前
字符函数和字符串函数
c语言·笔记·算法
夜月yeyue4 小时前
AUTOSAR CP 从上电到 Runnable
c语言·网络·tcp/ip·车载系统
微学AI5 小时前
一根针指向所有方向:挂谷猜想对 LLM Agent 技能-记忆架构的启示
开发语言·人工智能·架构·挂谷猜想
豆瓣鸡5 小时前
算法日记 - Day3
java·开发语言·算法
白白白小纯6 小时前
算法篇—反转链表
c语言·数据结构·算法·leetcode
韭菜炒鸡肝天6 小时前
VTK开发笔记(一):VTK介绍,Qt..+VSx+VTK.编译
开发语言·笔记·qt
小羊先生car6 小时前
RTOS-F429-HAL-绝对延时和相对延时(2026/7/31)
c语言·rtos
Aaron - Wistron7 小时前
Web API C# (Furion版)带 单元测试
开发语言·后端·c#
Dxy12393102168 小时前
Python项目打包成EXE完整教程(PyInstaller实战避坑)
开发语言·python
0566468 小时前
Python康复训练——常用标准库
开发语言·python·学习