精品偷拍一区二区三区,亚洲精品永久 码,亚洲综合日韩精品欧美国产,亚洲国产日韩a在线亚洲

  • <center id="usuqs"></center>
  • 
    
  • c#實(shí)現(xiàn),統(tǒng)計(jì)一句英文句子中某個(gè)單詞出現(xiàn)的次數(shù).

    c#實(shí)現(xiàn),統(tǒng)計(jì)一句英文句子中某個(gè)單詞出現(xiàn)的次數(shù).
    其他人氣:640 ℃時(shí)間:2020-05-19 18:57:15
    優(yōu)質(zhì)解答
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data.SqlClient;
    namespace ConsoleApplication1
    {
    class Program
    {
    static void Main(string[] args)
    {
    string s,s1,s2;
    int count = 0;
    Console.WriteLine ("請輸入你要查找的那個(gè)單詞的句子:");
    string str= Console.ReadLine ();
    Console.WriteLine ("請輸入你要查找的那個(gè)單詞:");
    string serchword= Console.ReadLine ();
    int sbcount = serchword.Count();
    for (int i = 0; i < str.Count(); i++)
    {
    if ( i == 0)
    {
    s1 = " ";
    s2 = str.Substring(i + sbcount ,1);
    s = str.Substring(i,sbcount);
    if (s1 == " " && s2 == " ")
    {
    if (s == serchword)
    count++;
    }
    }
    if (i + serchword.Count() < str.Count() && i != 0)
    {
    s1 = str.Substring(i - 1,1);
    s2 = str.Substring(i + sbcount-1 ,1);
    s = str.Substring(i,sbcount);
    if (s1 == " " && s2 == " ")
    {
    if (s == serchword)
    count++;
    }
    }
    if (i + serchword.Count() == str.Count() )
    {
    s1 = str.Substring(i - 1,1);
    s2 = " ";
    s = str.Substring(i,sbcount);
    if (s1 == " " && s2 == " ")
    {
    if (s == serchword)
    count++;
    }
    break;
    }
    }
    Console.WriteLine(count );
    Console.ReadLine();
    }
    }
    }你把題目說具體些,要在哪個(gè)控件上顯示數(shù)據(jù)上面是英文句子,而這里是字符串,到底是個(gè)英文句子(有空格的Look at the ball),還是隨便寫的,如 dfl j;thedfal; thesdjf 這里的the的個(gè)數(shù)哥們,不好意思,今天才看到,但是我發(fā)現(xiàn)你的還是有問題的,如果你輸入的內(nèi)容沒有the,就會不對,如ddgga,改成如下: string str = textBox1.Text.ToLower();int m = 0;for (int i = 0; i < str.Length; i++){int n = str.IndexOf("the") + 3;if (str.IndexOf("the") == -1)break;if (n > i) m++;str = str.Substring(n);}label1.Text = "the 出現(xiàn)的次數(shù)=" + m;下面是我做的,你可以參考下: int indexnumber = 0;string str = textBox1.Text.ToLower();int count= 0;for (int i = 0; i < str.Length; i++){indexnumber = str.IndexOf("the",indexnumber );if (indexnumber == -1)break;indexnumber++;count++;}label1.Text = "the 出現(xiàn)的次數(shù)=" + count;
    我來回答
    類似推薦
    請使用1024x768 IE6.0或更高版本瀏覽器瀏覽本站點(diǎn),以保證最佳閱讀效果。本頁提供作業(yè)小助手,一起搜作業(yè)以及作業(yè)好幫手最新版!
    版權(quán)所有 CopyRight © 2012-2024 作業(yè)小助手 All Rights Reserved. 手機(jī)版