本文實例講述了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);
}
}
}
}
更多關(guān)于C#相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《C#數(shù)據(jù)結(jié)構(gòu)與算法教程》、《C#程序設(shè)計之線程使用技巧總結(jié)》、《C#常見控件用法教程》、《WinForm控件用法總結(jié)》、《C#數(shù)組操作技巧總結(jié)》及《C#面向?qū)ο蟪绦蛟O(shè)計入門教程》
希望本文所述對大家C#程序設(shè)計有所幫助。
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!