gpt4 book ai didi

c - 作为初学者卡住 : C Programming

转载 作者:行者123 更新时间:2023-12-04 10:40:50 26 4
gpt4 key购买 nike

我这学期正在上 C 编程课,尽管没有满足先决条件,但不知何故被允许注册。我以为我还能应付得了,但现在我已经过了放弃它的不归路,我发现自己完全迷失了。

对于我当前的任务,我应该创建一个程序来执行一些简单的三角操作并显示结果。主要思想是有一栋建筑物,我站在离它一定距离的地方。

对于 A 部分,我必须计算建筑物的高度,假设我站在距离建筑物 120 米的地方,并在将头倾斜 30 度角(正/负 3 度)的同时看着顶部。

B 部分,假设建筑物高 200 英尺,而我站在 20 英尺外。我必须倾斜多少角度才能看到顶部?

C部分,根据B部分的信息,我的头到楼顶的距离(斜边)有多远?

到目前为止,我已经写了这个:

    #include <stdio.h> 
#include <math.h>
#define MAX_ANGLE 33
#define MIN_ANGLE 27
#define DIST_A 120
#define DIST_B 20
#define HEIGHT_B 200
#define PI 3.14159

int main()
(

double MIN_ANGLE_R, MAX_ANGLE_R;

MIN_ANGLE_R = MIN_ANGLE * (PI / 180);
MAX_ANGLE_R = MAX_ANGLE * (PI / 180);
min_height = DIST_A * tan(MIN_ANGLE);
max_height = DIST_A * tan(MAX_ANGLE);
angle = atan(HEIGHT_B/DIST_B)/(PI/180);
hypotenuse = HEIGHT_B/tan(angle);

printf ("The minimum height is %6.2f meters.\nThe maximum height is%6.2f meters.\n\n",min_height,max_height);
printf ("The angle that youw ill tilt your head to see\nthe top of the building is %3.2f feet.\n",angle);
printf ("The distance from your head to the top of the building is %6.2f feet.\n",hypotenuse);

return 0;
)

当我尝试编译程序时,我不断收到我不知道如何阅读的错误。如果有人能通读我的程序,并告诉我缺少什么,那将是一个巨大的帮助。

最佳答案

  1. 不要混淆 (){}。它们的含义不同。
  2. 声明您的变量。

关于c - 作为初学者卡住 : C Programming,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3681087/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com