用栈求逆序


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

namespace CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            Stack stk = new Stack();//先进后出
            do
            {
                Console.Write("请输入一个字符串:");
                stk.Push(Console.ReadLine());//压入
                Console.WriteLine();

                Console.WriteLine("是否要继续?");
            } while (Console.ReadLine() == "y");
            
            //不用做任何操作
            Console.WriteLine("倒序输出");
            foreach (string t in stk)
            {
                Console.WriteLine(t);
            }
        }

    }
}