C ++如何让计算机知道0100是100? [英] C++ How to let the computer know that 0100 is 100?

查看:66
本文介绍了C ++如何让计算机知道0100是100?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为初学者,我正在研究计算电话费的项目。谢谢大家,我的节目很棒..但是我又遇到了另一个问题,因为我的老师试图欺骗我这个..

他输入0100,他没有输入100所以这个程序'的计算是完全错误的。


我试图使用if语句,它在输入0100时有效,但在输入1000时它不起作用,它得到了一些错误的计算..每次我在时间之前输入0(如0800),程序无法正常工作......我不知道为什么!!


你能帮我解决这个问题吗?我很困惑。


As a beginner, I am working on a project that calculates the telephone bill. Thank you all, my program is great.. but I got another problem because my teacher was trying to trick me with this..
that he enter 0100, he didn''t enter 100 so the program''s calculation is totally wrong.

I have tried to use if statements, it works when entering 0100 but it does not work when entering 1000, it got some wrong calculation.. Everytime I enter 0 before the time (like 0800) the program doesn''t work properly.. I don''t know why!!

Can you guys help me out with this? I am so confused.


展开 | 选择 | Wrap | 行号

推荐答案

如果你放了一个调试break在第23行附近什么start_time有它的值,当你输入0800?
If you put a debug break near line 23 what to start_time have as it''s value, when you enter 0800?


0100,或任何其他带有前导零的数字,被解释为八进制数而不是但是,如果你的教授这样做并且没有告诉你关于八进制的信息,他就是一个混蛋。
0100, or any other number with a leading zero, is interpreted as an octal number rather than a number in base 10. Frankly, if your professor is doing that and hasn''t told you about octal, he''s being a bit of a jerk.



0100,o r具有前导零的任何其他数字,被解释为八进制数而不是基数10中的数字。坦率地说,如果你的教授这样做并且没有告诉你关于八进制的数字,那他就是一个混蛋。
0100, or any other number with a leading zero, is interpreted as an octal number rather than a number in base 10. Frankly, if your professor is doing that and hasn''t told you about octal, he''s being a bit of a jerk.



哦,好的电话。我忘记了。

Oh, good call. I forgot about that.


这篇关于C ++如何让计算机知道0100是100?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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