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;

}

相关推荐
for_ever_love__2 分钟前
PySpark学习: 数据输出
开发语言·python·学习·spark
言乐613 分钟前
Python实现自动拉人脚本示例
开发语言·windows·python·django·pygame
啊啊啊啊啊!!!!16 分钟前
【c++】二叉搜索树
开发语言·c++
归去来 兮34 分钟前
Python爬虫爬取数据案例
开发语言·爬虫·python
ShineWinsu36 分钟前
对于 C++:C++20中Concept(概念) 与 Coroutine(协程)的解析
linux·开发语言·网络·c++·c++20·epoll
ly768937 分钟前
C 语言从入门到进阶:语法、指针、内存管理与工程实践详解
c语言·开发语言
quantdash_cc1 小时前
历史数据断层与REST请求慢到崩溃?QuantDash高性能量化数据API终极解决方案
开发语言·python·缓存·php·量化·quantdash
breeze jiang1 小时前
Next.js 16 App Router 实战:从 About、Blog 动态路由到全局 404
开发语言·javascript·ecmascript
熊野君1 小时前
Prompt / RAG / 规则 / Skills —— 定位、协作与实现路线
开发语言·python
山甫aa2 小时前
JavaWeb后端开发学习手册
java·开发语言·数据库·学习·mysql·springboot·web