小编you*_*ide的帖子

河内的塔楼:将钉子从钉子移动到钉子

扩大我之前的帖子,我仍然在写河内塔.在解释了如何在钉子上画出环之后,我有一个很好的解决方案,我仍然有一个问题,我现在已经摆弄了很长一段时间.

这是我的PegClass:

namespace Towers_Of_Hanoi
{
    class PegClass
    {
        private int pegheight; 
        private int y = 3;
        int[] rings = new int[0];
        public PegClass()
        { 
            //this is the default constructor 
        }
        public PegClass(int height)
        { 
            pegheight = height; 
        }

        // other user defined functions 
        public void AddRing(int size)
        { 
            Array.Resize (ref rings, rings.Length + 2);
            rings[rings.Length - 1] = size;
        }

        public void DrawPeg(int x, int numberOfRings = 0)
        { 
            for (int i = pegheight; i >= 1; i--) 
            {
                string …
Run Code Online (Sandbox Code Playgroud)

.net c# windows console

9
推荐指数
1
解决办法
335
查看次数

标签 统计

.net ×1

c# ×1

console ×1

windows ×1