[译]魔术
By robot-v1.0
本文链接 https://www.kyfws.com/applications/a-magic-trick-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 3 分钟阅读 - 1184 个词 阅读量 0[译]魔术
原文地址:https://www.codeproject.com/Articles/5176/A-magic-trick
原文作者:David Crow
译文由本站 robot-v1.0 翻译
前言
A magic trick that will astound you!
一个神奇的把戏会让您吃惊!
介绍(Introduction)
虽然不是(While not a)*工具(tool)*从本质上讲,这个小"魔术"程序的灵感来自一个朋友给我的网站.我认为尝试并弄清楚他们是如何做到的很整洁.在短短的几分钟内,我和我的同事在一块大白板的帮助下,找到了解决方案.结果是一个基于向导的对话程序,试图读取您的想法!(per se, this little “magic” program was inspired by a Web site that a friend sent me. I thought it neat enough to try and figure out how they did it. Within just a few minutes, a co-worker and I, with the help of a big whiteboard, figured out a solution. The result is a wizard-based dialog program that attempts to read your mind!)
如何使用(How to use)
按照屏幕上的说明进行自我说明.基本上,您将记下一些数字,对它们进行一点点加扰,然后程序将尝试猜测您的一个数字.如果猜错了,请给我下一行,然后告诉我您使用的数字.我可能没有考虑所有例外情况.(Following the on-screen instructions, it’s self explanatory. Basically, you’re going to jot down some numbers, scramble ‘em up a bit, and the program will attempt to guess one of your numbers. If it guesses wrong, drop me a line and tell me the numbers you used. I may not have accounted for all exceptions.)
该程序不是万无一失的.可以给它一个伪造的数字,它反过来又给你一个伪造的答案.使其完全傻瓜会使代码过于复杂,而我已经做过一次.(The program is not fool-proof. It is possible to give it bogus numbers, and it will, in turn, give you a bogus answer. Making it totally fool-proof would have over-complicated the code, which I did once already.)
解决方案(The solution)
我选择不为这个难题提供解决方案,因为那样的话对于休闲的Web冲浪者来说太容易找到它了,从而破坏了他们原本想办法解决的所有乐趣-用他们的头!(I chose not to put a solution to the puzzle here, because then it would be way too easy for the casual Web surfer to find it, thus ruining any fun they might have had trying to figure it out the old fashioned way - using their head!)
但是,解决方案在于代码本身,并且很容易理解((A solution is, however, in the code itself, and is very easy to comprehend ()当有人向您展示如何简化数学时,甚至会更加轻松!(even easier when someone shows you how to simplify your math!)).我将挑战您尝试该程序或所引用的网站几次,然后再深入研究解决方案.(). I would challenge you to try the program, or the referenced Web site, a few times before diving right in and looking at the solution.)
参考文献(References)
-
米歇尔`瓦辛克(Michel Wassink)(Michel Wassink’s) 静态LED控制(static LED control)
-
直到我将所有这些放在一起,我才知道难题实际上有一个名字.我找到了一个很好的解释(It wasn’t until I had this all put together that I learned the puzzle actually had a name. I found a very nice explanation of it) 这里(here) .(.)
改进之处(Improvements)
UI有点夸张,但是由于我的意图不是华丽的程序,因此无关紧要.这些日子之一,我可能会倾向于打扮一下.如果您喜欢绘图和GDI类型的东西,请放心.(The UI is a bit blah, but since my intent was not a flashy program, it matters not. One of these days, I might be so inclined to dress it up a bit. If you like drawing and GDI type stuff, feel free.)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C++ VC6 Windows Win2K MFC Visual-Studio Dev 新闻 翻译