首页 新闻 会员 周边 捐助

这么多错误

0
[待解决问题]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _622
{
    class QueueTest
    {
        int [] array;
        int length=0;
        public QueueTest(int num)
        {
            array=new int[num];
        }
        public int length;
      {
        get
        {
          return this.length;
    }
      }
        public void Push(int num)
       {
           if(length>0)
             {
               for(int i=length-1;i>=0;i--)
               {
                array[i+1]=array[i];
               }
              }
         array[0]=num;
         length++;
        }
        public int Pop()
         {
          return array[--length];
         }
     }

    class Program
    {
        static void Main(string[] args)
        {
         QueueTest queue=new QueueTest(100);
         queue.Push(1);
         queue.Push(2);
         queue.Push(3);
         queue.Push(4);
        while(queue.Length>0)
         {
          Console.Write(queue.Pop()+"\t");
          }
          Console.Read();
        }
    }
}

居然有七个,看了半天,还是没该对,希望高手帮忙~

彼岸春秋的主页 彼岸春秋 | 初学一级 | 园豆:200
提问于:2011-04-07 20:23
< >
分享
所有回答(1)
0

class QueueTest
    {
        int[] array;
        int length = 0;
        public QueueTest(int num)
        {
            array = new int[num];
        }
        public int Length    ;
        {
            get
            {
                return this.length;
            }
        }
        public void Push(int num)
        {
            if (length > 0)
            {
                for (int i = length - 1; i >= 0; i--)
                {
                    array[i + 1] = array[i];
                }
            }
            array[0] = num;
            length++;
        }
        public int Pop()
        {
            return array[--length];
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            QueueTest queue = new QueueTest(100);
            queue.Push(1);
            queue.Push(2);
            queue.Push(3);
            queue.Push(4);
            while (queue.Length > 0)
            {
                Console.Write(queue.Pop() + "\t");
            }
            Console.Read();
        }
    }

Chenkun | 园豆:806 (小虾三级) | 2011-04-07 20:33
这是个错误,可貌似好是不行啊!
支持(0) 反对(0) 彼岸春秋 | 园豆:200 (初学一级) | 2011-04-07 20:49
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册