泛型求反序

来源:互联网 发布:手机怎么改淘宝用户名 编辑:程序博客网 时间:2024/04/30 01:51
/* * 烟台大学计算机学院学生    *All right reserved.    *文件名称:c#  *作者:孔云    *完成日期:2014年10月16日    *版本号:v1.0    *对任务及求解方法的描述部分:使用泛型类Stack<T>,实现字符串或数字的反序。 *我的程序: */using System;using System.Collections;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{    class Program    {        static void Main(string[] args)        {            Stack<char> st = new Stack<char>();           char[] t = {'E','I','7','9','W','H','2'};            for (int i = 0; i <t.Length; i++)            {                st.Push(t[i]);                         }            Console.WriteLine("反序后:");           for (int i = 0; i < t.Length; i++)            {               Console.Write(st.Pop());            }                      Console.ReadLine();        }    }}

0 0
原创粉丝点击