用C#编程:输入一些给定的字符串,统计它们各自出现的次数

2025-02-25 14:15:08
推荐回答(3个)
回答1:

using System;using System.Collections.Generic;using System.Linq;using System.Text;
namespace ConsoleApplication1{ class Program { static void Main(string[] args) { List record = new List() { "Hello","World","This","is","my","first","try","to","say","Hello" };
var query = from r in record group r by r.ToLower() into g select new { Count = g.Count(), Value = g.Key };
foreach (var v in query) { Console.WriteLine("Value = {0}, Count = {1}", v.Value, v.Count); } } }}使用LINQ TO OBJECT,一句话就搞定了

回答2:

附上程序#include #include using namespace std;int main(void)unsigned NumDigit(unsigned n);//我相信这个整数不会超过255位吧 unsigned res = 0; itoa(n, c, 10); for (int i = 0; c[i] != NULL; ++i) res++; return res;}
用C#编程:输入一些给定的字符串,统计它们各自出现的次数这里有视频教程可以看下 http://www.alisoho.com

回答3:

LZ你描述清楚点我帮你写