加载中…
个人资料
黄炳哲
黄炳哲
  • 博客等级:
  • 博客积分:0
  • 博客访问:17,735
  • 关注人气:14
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

【c#】对输入的字符串反序输出

(2009-11-29 18:50:40)
标签:

杂谈

分类: 技术文章

问题:编写一个控制台应用程序,它接收用户输入的一个字符串,将其中的字符以与输入相反的顺序输出。

代码:

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

namespace 字符串的处理
{
    class Program
    {
        static void sort(string str)
        {
            int count = str.Length;
            while (count>0)
            {
                Console.Write(str[count - 1]);
                count--;
            }
        }
        static void Main(string[] args)
        {
            string MyString = Console.ReadLine();
            Console.WriteLine("你输入的字符串:");
            foreach (char str in MyString)
            {
                Console.Write(str);
            }
            Console.WriteLine("\n逆序排列后:");
            sort(MyString);
            Console.ReadKey();
        }
    }
}

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有