qq群发言排行榜java源码_原创:QQ群发言统计

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Text.RegularExpressions;usingSystem.IO;namespaceQQGroupCount

{publicpartialclassQQGroupCounter : Form

{publicQQGroupCounter()

{

InitializeComponent();

}privatevoidbtnBroswer_Click(objectsender, EventArgs e)

{

openFileDialog1.ShowDialog();

}privatevoidopenFileDialog1_FileOk(objectsender, CancelEventArgs e)

{

txtFilePath.Text=openFileDialog1.FileName;

btnCount.Focus();

}privatevoidbtnCount_Click(objectsender, EventArgs e)

{

StreamReader sr=newStreamReader(txtFilePath.Text);

CountingContent(sr.ReadToEnd());

sr.Dispose();

}voidCountingContent(stringcontent)

{stringpattern=@"\d{4}[\-|/]\d{1,2}[\-|/]\d{1,2} \d{1,2}:\d{1,2}:\d{1,2} (.[^\(\)\]*)(\(\d+\)|\<.>]*\>)";

MatchCollection mc=Regex.Matches(content, pattern, RegexOptions.Multiline);

Listlist=newList();stringqq, name;foreach(Match minmc)

{

qq=m.Groups[2].Value.Replace('(','\0').Replace(')','\0').Replace('','\0');

name=m.Groups[1].Value;

QQUser user=list.Find(u=>u.QQ==qq);if(user==null)

user=list.Find(u=>u.NickName==name);if(user==null)

{

user=newQQUser();

user.QQ=qq;

user.NickName=name;

user.Count=1;

list.Add(user);

}else{

user.Count++;

user.NickName=name;

}

}

list=list.OrderByDescending(u=>u.Count).ToList();inti=0;foreach(QQUser userinlist)

{

i++;

user.Rank=i;

}

dataGridView1.DataSource=list;

}

}publicclassQQUser

{publicintRank {get;set; }publicstringNickName {get;set; }publicstringQQ {get;set; }publicintCount {get;set; }

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值