关于c#的编写,求个统计票数的代码编写工具

欢迎加入我们,一同切磋技术。 &
用户名: &&&
密 码: &
共有 1887 人关注过本帖
标题:求C#字符串拆分统计个数代码
等 级:新手上路
&&问题点数:0&&回复次数:6&&&
求C#字符串拆分统计个数代码
比如:aaa,中国,人民,bbb,中国,服务,中国,aaa,ccc
执行的结果出现多到少排列
结果:中国,aaa,人民,bbb,服务,ccc
(因为中国出现3,aaa出现2次,..)
搜索更多相关主题的帖子:
等 级:蒙面侠
帖 子:1096
专家分:4969
拆分=》统计=》合并=》排列
比较麻烦,没现成的方法
天涯无岁月,歧路有风尘,百年浑似醉,是非一片云
来 自:北京
等 级:贵宾
威 望:27
帖 子:1432
专家分:6329
程序代码:using S
using System.Collections.G
using System.T
namespace StringSplit
&&& class Program
&&&&&&&&static void Main(string[] args)
&&&&&&&&&&&&string&&test = &aaa,中国,人民,bbb,中国,服务,中国,aaa,ccc&;
&&&&&&&&&&&&foreach (StringTimes st in GetStringAndTimes(test))
&&&&&&&&&&&&{
&&&&&&&&&&&&&&& Console.WriteLine(st.timers+ &,& + st.value);
&&&&&&&&&&&&}
&&&&&&&&&&&&//foreach (StringTimes st in OrderByTimers(GetStringAndTimes(test)))
&&&&&&&&&&&&//{
&&&&&&&&&&&&//&&& Console.WriteLine(st.value + &-出现次数& + st.timers.ToString() + &;&);
&&&&&&&&&&&&//}
&&&&&&&&&&&&Console.WriteLine(&根据出现次数排序后:&);
&&&&&&&&&&&&foreach (StringTimes st in OrderByTimers(GetStringAndTimes(test)))
&&&&&&&&&&&&{
&&&&&&&&&&&&&&& Console.Write(st.value + & &);
&&&&&&&&&&&&}
&&&&&&&&&&&&Console.ReadKey();
&&&&&&&&//对StringTimes进行排序
&&&&&&&&static List&StringTimes& OrderByTimers(List&StringTimes& ST)
&&&&&&&&&&&&List&StringTimes& st = ST;
&&&&&&&&&&&&for (int i = 0; i & st.C i++)
&&&&&&&&&&&&{
&&&&&&&&&&&&&&& int currentTimes = st[i].
&&&&&&&&&&&&&&& for (int j = j & st.C j++)
&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&&&if (st[j].timers & currentTimes)
&&&&&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&&&&&StringTimes tempInt = st[i];
&&&&&&&&&&&&&&&&&&&&&&&&st[i] = st[j];
&&&&&&&&&&&&&&&&&&&&&&&&st[j] = tempI
&&&&&&&&&&&&&&&&&&&&&&&&currentTimes = st[j].
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&else
&&&&&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&& }
&&&&&&&&&&&&}
&&&&&&&&&&&&
&&&&&& static List&StringTimes& GetStringAndTimes(string Str)
&&&&&&&&&&&&List&StringTimes& timesAndString = new List&StringTimes&();
&&&&&&&&&&&&string[] strArray = Str.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
&&&&&&&&&&&&foreach (string str in strArray)
&&&&&&&&&&&&{
&&&&&&&&&&&&&&& bool hasShow =
&&&&&&&&&&&&&&& foreach (StringTimes st in timesAndString)
&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&&&if (str == st.value)
&&&&&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&&&&&st.timers++;
&&&&&&&&&&&&&&&&&&&&&&&&hasShow =
&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&&&&&&&else
&&&&&&&&&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&}
&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&& if(!hasShow)
&&&&&&&&&&&&&&&&&&&&timesAndString.Add(new StringTimes(1, str));
&&&&&&&&&&&&}
&&&&&&&&&&&&return timesAndS
&&&&&& class StringTimes
&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&&public StringTimes(int Timers, string Value)
&&&&&&&&&&&&{
&&&&&&&&&&&&&&& this.timers = T
&&&&&&&&&&&&&&& this.value = V
&&&&&&&&&&&&}
看看这个吧..
首先计算字符串出现的次数,然后根据出现次数进行排序,输出。
可能有点绕..我写了快半个小时。。
呵呵,你还一分都不给..
等 级:新手上路
恩,值得学习。我顶
等 级:新手上路
帖 子:18
先收藏,谢谢。
来 自:广西
等 级:新手上路
帖 子:12
自己写点算法都不会吗?
搞这行的,需要头脑
等 级:新手上路
帖 子:94
把它们为成几个string数组,然后用compare依次进行比较,算出(统计)它们的返回值,存在几个变量里面,然后对比一下结果就出来了。。。但是,,,,怎么区别&&哪个变量对应哪个字串,我是我的思路。。。。。。。。。。。。。。。。。。。。。。。。
版权所有,并保留所有权利。
Powered by , Processed in 0.036670 second(s), 7 queries.
Copyright&, BCCN.NET, All Rights Reserved君,已阅读到文档的结尾了呢~~
软件源代码:数得明白-用C#制作源代码统计&软件&疯狂代码&http://www.crazycoder.cn/&:http:/www.crazycoder.cn/DotNet/Article8982.html&我们在招聘会上经常看到这样要求:&熟练使用XX语言有X万行源码经验&确实编码行数在定程度上反映了...
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
软件源代码:数得明白-用C#制作源代码统计
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer-.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口C#源代码统计程序 - 拙言 - CSDN博客
C#源代码统计程序
要求:从命令行输入一个参数(指定目录或文件),输出该目录下指定类型文件(.cs, .java)的个数、每个文件的总行数、空行数、注释行数、代码行数。
using System.IO;
namespace ConsoleApplication1
& & #region
& & class Program
& & & & static int cLine = 0;
& & & & static int nLine = 0;
& & & & static int sLine = 0;
& & & & static void &CountLine(string file)
& & & & & & FileStream stream = new FileStream(file, FileMode.Open);
& & & & & & StreamReader reader = new StreamReader(stream);
& & & & & & string line = reader.ReadLine();
& & & & & & while (line != null)
& & & & & & {
& & & & & & & & if (line.Trim() != && && !(line.Trim().StartsWith(@&//&)))
& & & & & & & & {
& & & & & & & & & & cLine++;
& & & & & & & & }
& & & & & & & & else if (line.Trim().StartsWith(@&//&))
& & & & & & & & {
& & & & & & & & & & sLine++;
& & & & & & & & }
& & & & & & & & else
& & & & & & & & {
& & & & & & & & & & nLine++;
& & & & & & & & }
& & & & & & & & line = reader.ReadLine();
& & & & & & }
& & & & & & reader.Close();
& & & & static void DirectoryCountLine(string directory)
& & & & & & foreach (string file in Directory.GetFiles(directory, &*.cs&))
& & & & & & {
& & & & & & & & CountLine(file);
& & & & & & }
& & & & static void Main(string[] args)
& & & & & & Console.Write(&请输入要查询的目录地址:&);
& & & & & & string dir = Console.ReadLine();
& & & & & & DirectoryCountLine(dir);
& & & & & & Console.WriteLine(&该目录下的cs文件的代码行的行数为{0}&, cLine);
& & & & & & Console.WriteLine(&该目录下的cs文件的注释行的行数为{0}&, nLine);
& & & & & & Console.WriteLine(&该目录下的cs文件的空白行的行数为{0}&, sLine);
& & & & & & Console.WriteLine(&该目录下的cs文件总的代码行的行数为{0}&, cLine + nLine + sLine);
& & & & & & Console.Read();
& & #endregion
运行结果如图:
我的热门文章&C# 代码统计工具 代码行数统计
秒后自动跳转到登录页
快捷登录:
举报类型:
不规范:上传重复资源
不规范:标题与实际内容不符
不规范:资源无法下载或使用
其他不规范行为
违规:资源涉及侵权
违规:含有危害国家安全等内容
违规:含有反动/色情等内容
违规:广告内容
详细原因:
任何违反下载中心规定的资源,欢迎Down友监督举报,第一举报人可获5-10下载豆奖励。
视频课程推荐
C# 代码统计工具 代码行数统计
上传时间:
技术分类:
资源评价:
(1位用户参与评价)
已被下载&4&次
C# 代码统计工具 代码行数统计
本资料共包含以下附件:
C# 代码统计工具 代码行数统计.zip
51CTO下载中心常见问题:
1.如何获得下载豆?
1)上传资料
2)评论资料
3)每天在首页签到领取
4)购买VIP会员服务,无需下载豆下载资源
5)更多途径:点击此处
2.如何删除自己的资料?
下载资料意味着您已同意遵守以下协议:
1.资料的所有权益归上传用户所有
2.未经权益所有人同意,不得将资料中的内容挪作商业或盈利用途
3.51CTO下载中心仅提供资料交流平台,并不对任何资料负责
4.本站资料中如有侵权或不适当内容,请邮件与我们联系()
5.本站不保证资源的准确性、安全性和完整性, 同时也不承担用户因使用这些资料对自己和他人造成任何形式的伤害或损失
相关专题推荐
本视频教程一共二十讲,以英文版的《
本套视频是由徐长龙老师主讲,作为微
WinForm可以创建应用程序的用户界面,
本专题为.net平台的C#教学视频,共54
本专题为《软件开发视频大讲堂·C#从
精选53个ASP.NET开发中最常用的模块,
本专题详细介绍WCF通信的原理和应用,
本专题精选了21个来源于开发第一线的
本专题收集了20个具有代表性的项目实
ASP.NET是微软主流企业Web应用开发技
精选22个经典小游戏:俄罗斯方块、坦
本专题为传智播客.Net培训第10季 ASP
本专题为C#4.0从入门到精通视频教程,
9大专题:.Net基础加强,数据库开发及
本专题包括家庭视频监控、企业短信群
主讲教材《Visual C# 2010从入门到精
意见或建议:
联系方式:
您已提交成功!感谢您的宝贵意见,我们会尽快处理

我要回帖

更多关于 易语言代码编写例子 的文章

 

随机推荐