一个简单的控制台魔方中的C(没有需要解决的,只有设计) [英] A simple console Rubik's cube in C (No need to solve, only design)

查看:125
本文介绍了一个简单的控制台魔方中的C(没有需要解决的,只有设计)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,作为一个初学者,这个程序是给我的偏头痛。当然,我不要求任何完整的code,我想了解的逻辑和我的选择。

So, as a beginner, this program is giving me a migraine. Of course, I'm not asking for any complete code, I want to understand the logic and my options.

在大学,我们已经覆盖(或将覆盖)的C语言编程的题目不超过动态数组。我们可以利用结构,功能,数组,指针但不是类,因为这是C,而不是C ++。

In university, the topics in C programming we have covered (or will cover) do not exceed Dynamic arrays. We can use structures, functions, arrays, pointers but not classes because this is C, not C++.

我很好的解决方案,但不是难题。我已经试过是使一个立方体的结构 6的整数(重新present侧),然后进行数组立方体

I'm good with solutions, but not puzzles. What I've tried is making a cube struct with 6 integers (to represent sides), and then make an array of cube.

我可以做的另一件事是做一个[6] [3] [3]数组,但我认为这会让它太复杂?总结我在问什么,

Another thing I can do is make a [6][3][3] array but I think that'd make it too complex? To summarize what I'm asking,


  • 控制台应用程序

  • 没有花哨的图形或任何

  • 无解

  • 一个简单的立方体工作

  • 可以初始化用户输入

等级:业余

这是正确的做法?你怎么认为我应该旋转行?同样,不需要code,如果你能解释一下主要的逻辑,我应该怎么分手的code,甚至伪code,那简直太好了。

Is this the right approach? How do you think I should rotate a line? Again, no need for code, if you can please explain the main logic and how should I break up the code or even Pseudo-code, that'd be great.

你觉得我应该在所有使用立方体构成一个整体的立方体魔方[3] [3] [3] 或处理的脸像立方体表面[3] [3]

Do you think I should make a whole cube at all using cube rubik[3][3][3] or deal with face like cube face[3][3]?

我要添加您需要帮助解决我的问题,任何额外的信息。

I'll add any extra information you require to help solve my problem.

编辑 - 附加信息:
这是我的立方体阵列(这里搞砸缩进了一下编辑器):

EDIT - Additional Info: This is my cube array (the editor here messed up the indentation a bit):

int cube[6][3][3] = {{{1,1,1},{1,1,1},{1,1,1}}, 
            {{2,2,2},{2,2,2},{2,2,2}}, 
            {{3,3,3},{3,3,3},{3,3,3}},
            {{4,4,4},{4,4,4},{4,4,4}},
            {{5,5,5},{5,5,5},{5,5,5}},
            {{6,6,6},{6,6,6},{6,6,6}}  };


通过

推荐答案

立方体可以重新$ P $

a cube can be represented by

int tile[6][3][3];

的第一个索引是立方体的面

the first index is the face of the cube

第二和第三重present行和列

the second and the third represent the row and the column

数组的值是色彩(0-5)

the value of the array is the color (0-5)

这可以在一个立方体进行操作是6个面(因此6可能采取的行动)。

Action that can be performed on a cube are a 90° clockwise rotation of one of the 6 faces (so 6 possible actions).

任何其他lecit动作可再通过上述的序列psented $ P $

Any other lecit action can be represented by a sequence of the above.

有关完整性,即使它没有要求,要解决这一难题最简单的办法就是暴力破解尝试,直到找到解决办法的招式所有可能的序列。但是,这将导致存储器和处理器非常低效的使用。如溶液中20移动通常发现一个最坏的情况下会导致试图围绕1.0E14移动...

For completeness, even if it's not asked, the easiest way to solve the puzzle is to bruteforce try all possible sequence of moves until a solution is found. But that would result in very inefficient usage of memory and processor. As solution is usually found in 20 moves a worst case scenario would result in trying around 1.0E14 moves...

该网站有大量的谜题求解算法...

The web has plenty of puzzle solution algorithms...

这篇关于一个简单的控制台魔方中的C(没有需要解决的,只有设计)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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