帮助解决基本的C问题 [英] Help with basic C problem
问题描述
您好,
我明天有一项作业,我已经尝试调试一周了。谷歌很难找到正在发生的事情。
问题是使用功能分解编写一个C ++程序来确定三个输入数字的中位数。 ..
到目前为止,我所做的计划将会这样做,但只有整数。如果我输入应该使用的浮点值,我什么也得不到。
这是关于条件,逻辑表达式和选择控制结构的章节,只是为了让你知道我在哪里。
这是我的代码片段。我声明的浮点变量是num1,num2和num3。这些数字由用户通过cin输入。
Hello,
I have an assignment due tomorrow that I''ve been trying to debug for a week. Google has failed me horribly at finding out what''s going on.
The problem is to "use functional decomposition to write a C++ program that determines the median of three input numbers..."
So far the program that I''ve made will do this, but only with whole numbers. If I enter the floating point values that are supposed to be used I get nothing.
This is in the chapter for conditions, logical expressions, and selection control structures, just to let you know where I am.
Here''s a snippet of my code. My declared floating point variables are num1, num2, and num3. The numbers are entered by the user via cin.
推荐答案
Doesn''似乎涵盖了整个事情。
快速提问,为什么不把它们扔进矢量,排序并打印中间数字?
Doesn''t seem to cover the whole thing.
Quick question, why don''t you just toss em into a vector, sort it and print the middle number?
似乎无法涵盖整个事情。
快速问题,为什么不是你将em扔进矢量,排序并打印中间数字?
Doesn''t seem to cover the whole thing.
Quick question, why don''t you just toss em into a vector, sort it and print the middle number?
我们还没有涵盖这个课程。这是''班级的基础'。
我不想发布我的整个作业,但似乎如果我使用任何浮点数,它只是跳过整个if / else if结构,然后直接捕捉到其他所有结尾。
We haven''t covered that yet in this class. This is a ''basics of'' class.
I don''t want to post up my entire assignment, but it seems that if I use any floating point number, it just skips the entire if/else if structure and goes right to a catch all else at the end.
好的,进一步的调试发现它不是浮点数引起的问题,但任何具有一定数字有效数字的数字。
任何想法?
Okay, further debugging has found that it isn''t floating point numbers causing the problem, but any numbers with a certain amount of significant digits.
Any ideas?
这篇关于帮助解决基本的C问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!