1using System;
 2
 3namespace test14
 4{
 5    /// <summary>
 6    /// Class1 的摘要说明。
 7    /// </summary>

 8    class Class1
 9    {
10        /// <summary>
11        /// 编写一个方法,统计输入的英语字符串有多少个英文单词组成,
12        /// 假设输入的字符串只用空格,逗号,句号分隔
13        /// </summary>

14        [STAThread]
15        static void Main(string[] args)
16        {
17            string mystring = "I love you";
18            Console.WriteLine(CountWords(mystring));
19
20        }

21        public static int CountWords(string input)
22        {
23            string[] s;
24            s = input.Split(new char[]{' ',',','.'});
25            return s.Length;
26        }

27    }

28}

29

只有注册用户登录后才能发表评论。

posts - 46, comments - 16, trackbacks - 0, articles - 7

Copyright © 火山工作室