C#實現(xiàn)用棧求逆序的方法示例
更新時間:2017年07月10日 08:49:38 作者:a771948524
這篇文章主要介紹了C#實現(xiàn)用棧求逆序的方法,涉及C#數(shù)據(jù)結構中棧的壓入與取出相關操作技巧,需要的朋友可以參考下
本文實例講述了C#實現(xiàn)用棧求逆序的方法。分享給大家供大家參考,具體如下:
用棧求逆序
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("是否要繼續(xù)?"); } while (Console.ReadLine() == "y"); //不用做任何操作 Console.WriteLine("倒序輸出"); foreach (string t in stk) { Console.WriteLine(t); } } } }
更多關于C#相關內容感興趣的讀者可查看本站專題:《C#數(shù)據(jù)結構與算法教程》、《C#程序設計之線程使用技巧總結》、《C#常見控件用法教程》、《WinForm控件用法總結》、《C#數(shù)組操作技巧總結》及《C#面向對象程序設計入門教程》
希望本文所述對大家C#程序設計有所幫助。
您可能感興趣的文章:
相關文章
C#實現(xiàn)復制數(shù)據(jù)庫 C#將A數(shù)據(jù)庫數(shù)據(jù)轉到B數(shù)據(jù)庫
這篇文章主要為大家詳細介紹了C#復制數(shù)據(jù)庫,將數(shù)據(jù)庫數(shù)據(jù)轉到另一個數(shù)據(jù)庫,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-11-11C#接口INotifyPropertyChanged使用方法
這篇文章介紹了C#接口INotifyPropertyChanged的使用方法,文中通過示例代碼介紹的非常詳細。對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-01-01