为什么我的输出返回变量时间和高度的随机值?寻找指导而不是直接回答。 [英] Why is my output returning random values for the variables time and height? Looking for guidance rather then straight answer.

查看:78
本文介绍了为什么我的输出返回变量时间和高度的随机值?寻找指导而不是直接回答。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include <stdio.h>
#include <math.h>
#define G 32

int main(){
    int i=0, t=1, distance, D=(1/2)*G* pow(1,2), height=distance-D;

    printf("What is the height of the dragon's nest in feet?\n ");
    scanf("%d", &distance);
    printf("Time\tAltitude\n");

        if (distance<= 0)
            printf("0\t0\n");

        while (distance>0) {
            D=distance-D;
            printf("%d\t%d.\n",t, D);
            }

return 0;
}

推荐答案

如果你想了解这个程序有什么问题,我建议在调试器模式下运行它。

一步一步地运行它并根据预期值检查变量,你应该看到错误很快。



首先提示^不是你想的那样。阅读解决方案的文档。



我想tittle是应该做的程序。所以甚至没有问题。
If you want to understand what is wrong in this program, I suggest to run it in debugger mode.
Run it step by step and check variables against expected values, you should see pretty fast what is wrong.

First hint "^" is not what you think it is. Read documentation for solution.

I guess the tittle is what is supposed to do the program. So there is not even a question.


这篇关于为什么我的输出返回变量时间和高度的随机值?寻找指导而不是直接回答。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆