日期:2014-05-17  浏览次数:21085 次

有关一些字符串练习的答案
这是c#基础班,苏坤老师讲字符串时留下的作业
课上练习1:接收用户输入的字符串,将其中的字符以与输入相反的顺序输出。"abc"→"cba"
课上练习2:接收用户输入的一句英文,将其中的单词以反序输出。"hello c sharp"→"sharp c hello"
课上练习3:从Email中提取出用户名和域名:abc@163.com。
课上练习4:让用户输入一句话,找出所有e的位置
由于没有接下来的视频了,我将这4道题做了,下面是我做的程序,都调试过了,但是感觉比较原始,不知道苏老师是怎么做的。
麻烦坛子里的高手帮忙看看,也好帮我我理一下思路,看看有没有简单的方法,谢谢了
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace string_练习
{
    class Program
    {
        static void Main(string[] args)
        {
            ////将一组字符串反向输出,输入abc,输出cba
            //string recive = "";
            //char[] chars = null;
            //char temp = '0';
            //int i = 0;
            //Console.WriteLine("请输入一组字符串");
            //recive = Console.ReadLine();
            //chars = recive.ToCharArray();
            //for (i = 0; i < (chars.Length - 1) / 2; i++)
            //{
            //    temp = chars;
            //    chars = chars[chars.Length - i - 1];
            //    chars[chars.Length - i - 1] = temp;
            //}
            //recive = new string(chars);
            //Console.WriteLine(recive);

            //反向输出一组单词 输入hello world 输出 world hello
            //string recive = "", input = "";
            //string temp = "";
            //Console.WriteLine("请输入一句话");
            //recive = Console.ReadLine();
            //string[] get = null;
            //char[] chars = { ' ' };
            //get = recive.Split(chars, StringSplitOptions.None);
            //int i = 0;
            //for (i = 0; i < (get.Leng