如何修复损坏的程序 [英] How to fix a broken program

查看:86
本文介绍了如何修复损坏的程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图制作一个用于计算轨道物体质量的程序 - 但它几乎总计。如果有人可以解决这个问题,我将永远感恩。这是代码,祝你好运。



I tried to make a program for calculating the mass of an orbiting body- but Its pretty much totaled. If someone could sort this mess out I will be eternally thankful. Here's the code, good luck.

#include <iostream>
int main()
using namespace std;{


int main ()
{
	system("pause");
	int i;
	cout <<"Input orbital period in seconds: ";
	cin >> t;
	cout << "Orbital time= " << t;
	cout << "Input Object distance from sun in meters: ";
	(cin >> d;
	cout << "Orbital distance= " << d;
	
	g = (6.6 * 10^-11)

	m = (d^3 * (4 * 3.14159)^2) / (g * (t^2))

	cout << "Object mass= " << m;

	

}</iostream>

推荐答案

请看我对这个问题的评论(相当一个非问题)。



不,这不是一个破碎的程序,这是一个永远不会有的程序已经写好了,所以没有什么可以打破的。而且,我想,你从来没有学过您假装写入的语言。例如,您需要声明所有变量,使用类型 double 进行计算,计算功率,您必须使用函数 pow http://www.cplusplus.com/reference/cmath/ pow [ ^ ]),依此类推。



不,除了好踢之外你不需要任何帮助:坐下来学习这门课程,学习如何完成这项工作。



-SA
Please see my comment to the question (rather a non-question).

No, this is not a "broken program", this is a program which never has been written, so there is nothing to break. And, I guess, you never learned the language you pretend to write in. For example, you need to declare all variables, use the type double for your calculations, to calculate power, you have to use the function pow (http://www.cplusplus.com/reference/cmath/pow[^]), and so on.

No, you need no help except a good kick: sit down and learn the subject, to learn how to do the job.

—SA


在C / C ++中,与许多其他编程语言一样,^表示XOR运算符而不是指数。



所以你写的6.6 * 10 ^ -11应写成6.6e-11。同样适用于配方中的Pow。对于2的幂,人们通常会写出类似(t * t)的东西,因为它更有效率并且非常普遍。对于其他功能,通常会使用标准库中的pow函数。
In C/C++ as in many other programming language ^ denote the XOR operator and not an exponent.

So what you have written as 6.6 * 10^-11 should be written as 6.6e-11. The same apply for Pow in formula. For a power of two, one would usually write something like (t * t) since it is more efficiency and quite common. For other function, one would generally use pow function from the standard library.


您的解决方案:学习语言



您实际上是在要求我们每次进行更改时通过重新发布相同的程序逐步为您执行该程序。

如何让程序暂停? [ ^ ]



那是滥用
Your solution: Learn the language

You are actually asking us to do the program for you incrementally by Reposting the same program every time you make a change.
How do I get a program to pause?[^]

That is Abusive


这篇关于如何修复损坏的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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