分享
 
 
 

qq群 发言统计for tc

王朝other·作者佚名  2006-01-10
窄屏简体版  字體: |||超大  

.S0 {

color: #808080;

background: #FFFFFF;

}

.S1 {

font-family: 'Comic Sans MS';

color: #007F00;

background: #FFFFFF;

font-size: 9pt;

}

.S4 {

color: #007F7F;

background: #FFFFFF;

}

.S5 {

font-weight: bold;

color: #00007F;

background: #FFFFFF;

}

.S6 {

color: #7F007F;

background: #FFFFFF;

}

.S7 {

color: #7F007F;

background: #FFFFFF;

}

.S9 {

color: #7F7F00;

background: #FFFFFF;

}

.S10 {

font-weight: bold;

color: #000000;

background: #FFFFFF;

}

span {

font-family: 'Verdana';

color: #000000;

background: #FFFFFF;

font-size: 10pt;

}

/*

* 本程序 使用 tc 2.01 编译通过

* 10751331 is QQ group No.

* 把群聊天记录 导出成一个liao.txt 文本文件

* 先登陆群社区然后使用下面网址

* http://group.qq.com/cgi-bin/showGroupMpjPage?PageType=5&CurPage=0&GroupId=10751331

* 得到所有现在群人员名单 保存为name.txt

* 格式为:

* vincent/mg[100011931] 你是我HAppy[76865684] 輕憶/;![76969318]

* Sky↑Archer[77050750] 雨[77434994] 書生小強/aiq[78121686]

* 这两个文件都放在原文件同一个目录

*/

#include <stdlib.h>

#include <stdio.h>

#include <ctype.h>

#include <string.h>

#include <conio.h>

#define SS "2005-07-21"

#define TIME "16:52:33"

#define QQ 15

#define NAME 30

#define DAY 13

#define TEMP 30

typedef struct list

{

char qq[QQ];

char name[NAME];

char day[DAY];

char temp[TEMP];

int count;

struct list *next;

}L;

int getline(FILE *fp,char arry[]);

int liu(void); /* 过滤代码 */

int tests(char str[],char text[],int a,int b); /* 测试字符串 */

int inslist(char name[],L *list,char day[],char qq[]);/*插入人名 && 计算 次数*/

void findname(L *head); /*从 name.txt 提取名单 */

int findqq(char name[],char qq[]); /* 从字符串中搜索 qq号码 */

void freelist(L *head); /*销毁链表 */

void paixu(L *head); /* 排序链表 */

L * creatlist(void); /* 创建空链表 */

main()

{

L *head;

FILE *fp, *wp;

int test = 0; /*test*/

char day[DAY];

char name[NAME];

char temp[TEMP];

char qq[QQ];

liu(); /*过滤文件 */

head = creatlist();

findname(head);

fp = fopen("qq.tmp","r");

if (NULL == fp) {

printf("Not Open the qq.tmp file\n");

exit (1);

}

wp = fopen("newqq.txt","w");

if (NULL == wp) {

printf("Not W the newqq.txt file\n");

exit (1);

}

while( fscanf(fp,"%30s",day) != EOF ){

if ( tests(day,SS,0,5) ){

fscanf(fp,"%s",temp);

if ( tests(temp,TIME,2,2) ){

getline(fp,name);

if( findqq(name,qq) ){

inslist(name,head,day,qq);

}

}

}

}

/* printf("head : %d \n",head->count); */

paixu(head);

fprintf(wp,"一共有成员 %d \n"

"-------------------------------------------\n"

"%10s%14s%11s%10s\n\n"

,head->count,"QQ号码"," 姓名 ","最后日期"," 次数 ");

do{

++test;

/* head = head -> next; */

/* printf("qq: %s\n",head->qq); */

head = head -> next;

fprintf(wp,"%10s",head->qq);

fprintf(wp," ");

fprintf(wp,"%14s",head->name);

fprintf(wp," ");

fprintf(wp,"%11s",head->day);

fprintf(wp," ");

fprintf(wp,"%4d\n",head->count);

}

while (NULL != head -> next);

printf("%d\n",test);

fclose(wp);

fclose(fp);

freelist(head);

if (!remove("qq.tmp") )

printf("remove file OK!\n");

else printf("remove file Error !\n");

printf("done !!\n");

getch();

return 0;

}/* main() */

int tests(char str[],char text[],int a,int b)

{

int i = 0;

while ( str[i] != '\0' )

++i;

if ( i < b )

return 0;

while(a <= b){

if(str[a] != text[a])

return 0;

/* printf("str:%c text:%c\n",str[a],text[a]); */

/* getch(); */

++a;

}

return 1;

}

int inslist(char name[],L *list,char day[],char qq[])

{

L *head;

L *newl;

head = list;

/* printf("list next:%d\n",list->next); */

if (list -> next == NULL){

newl = (L *)malloc( sizeof(L) );

if (newl == NULL) {

printf("!!error malloc\n");

exit(1);

}

newl->next = NULL;

newl->count = 0;

strcpy(newl->qq,qq);

strcpy(newl->name,name);

strcpy(newl->day,day);

list -> next = newl;

++head -> count;

printf("new list\n");

return 1;

}

do{

list = list -> next;

/* printf("%s : %s\n",list->qq,qq); */

/* getch(); */

if ( !strcmp(list->qq,qq) ){

++ list -> count;

strcpy(list -> day,day);

strcpy(list -> name,name);

return 0;

}

}

while (list -> next != NULL);

/* printf("add a new NOD \n"); */

if( !strcmp(day,"0000") ) {

newl = (L *)malloc( sizeof(L) );

if (newl == NULL) {

printf("!!error malloc\n");

exit(1);

}

strcpy(newl->qq,qq);

strcpy(newl->name,name);

strcpy(newl->day,day);

newl -> count = 0;

newl -> next = NULL;

list -> next = newl;

++head -> count;

/*printf("inster new save qq :%s\n",qq); */

return 1;

}

return 0;

}/* inslist () */

L * creatlist(void)

{

L *new;

new = (L *)malloc( sizeof(L) );

if (new == NULL) {

printf("!!error malloc\n");

exit(1);

}

new -> qq[0] = '\0';

new -> name[0] = '\0';

new -> day[0] = '\0';

new -> count = 0;

new -> next = NULL;

printf("creatlist OK\n");

return new;

} /* creatlist() */

void freelist(L *head)

{

L *temp;

temp = head -> next;

free(head);

head = temp;

}/* freelist() */

int findqq(char name[],char qq[])

{

int size, i, pot;

size = strlen(name);

/* printf("size : %d is name %s \n",size,name); */

if (name[size-1] != ')')

return 0; /* qq No. error */

/* printf("find ) is : %c\n",name[size]); */

i = 0;

while( name[size-i] != '(') {

++i;

if(size-i < 0)

return 0; /* not find '(' error */

}

pot = size - i;

for (i = 0; pot + i +1<= size-2; i++){

qq[i] = name[pot + i+1];

/* printf("qq[%d]: %c\n",i,qq[i]); */

}

qq[i] = '\0';

name[pot] = '\0';

return 1;

}/* findqq */

void paixu(L *head)

{

L *list,*r, *temp, *hhead;

int max, i, l;

hhead = head;

max = head -> count;

printf("max: %d\n",max);

for (i = 0; i < max; i++){

head = hhead;

for (l = 0; l < max;l++){

list = head -> next;

r = list -> next;

if(list->count > r->count){

/*printf("l: %d\n",l); */

/* printf("rver list:%d r:%d \n",list->count,r->count);

getch(); */

temp = head->next;

head->next = list->next;

list -> next = r->next;

r->next = temp;

}

head = head->next;

}

}

}/* paixu() */

void findname(L *head)

{

FILE *np;

int ch;

int i = 0;

int flag = 0;

int temp ;

char name[NAME];

char qq[QQ];

np = fopen("name.txt","r");

if (NULL == np){

printf("Not Open the name.txt file\n");

exit (1);

}

while( !feof(np) ){

while( isspace ( ch=fgetc(np) ))

;

if ('[' == ch){

temp = fgetc(np);

if ( isdigit(temp) ){

name[i] = '\0';

flag = 1;

ch = temp;

i = 0;

}else ch = temp;

/* a name to save done */

}

if (']' == ch && 1 == flag){

flag = 0;

qq[i] = '\0';

ch = ' ';

i = 0;

inslist(name,head,"0000",qq);

/* a qq number to save done */

}

if (0 == flag){

name[i] = ch;

++i;

}

if (1 == flag){

qq[i] = ch;

/* printf("qq[%d]:%c\n",i,qq[i]); */

++i;

}

}

fclose(np);

printf("name find done !!\n");

getch();

}/* findname() */

/* 过滤代码 */

/* \x14 \x0a || \x0b \x14 \x0a || \x0b \x14 */

int liu(void)

{

FILE *fp, *wp;

int ch;

int flag = 0;

fp = fopen("liao.txt","rb"); /* 聊天记录导出文件 */

if (NULL == fp) {

printf("Not Open the liao.txt file\n");

exit (1);

}

wp = fopen("qq.tmp","wb"); /* 生成新的文件 */

if (NULL == wp) {

printf("Not WP to qq.tmp file\n");

exit (1);

}

while (!feof(fp)){

flag = 0;

ch = fgetc(fp);

if ('\x14' == ch){

/*temp = ch; */

ch = fgetc(fp);

if ('\x0a' == ch)

;

else if ('\x0d' == ch){

ch = fgetc(fp);

if ('\x0a' == ch)

ch = fgetc(fp);

fputc(ch,wp);

}

else fputc(ch,wp);

flag = 1;

}

if ('\x0b' == ch){

ch = fgetc(fp);

if ('\x14' == ch){

ch = fgetc(fp);

if('\x0a' == ch)

;

else fputc(ch,wp);

}else fputc(ch,wp);

flag = 1;

}

if ('\x1a' == ch){

flag = 1;

}

if (0 == flag ){

fputc(ch,wp);

}

}

fclose(fp);

fclose(wp);

printf("liu done !!!!! \n");

getch();

return 0;

}

int getline(FILE *fp,char arry[])

{

char ch;

int i = 0;

int flag = 0;

while ( isspace ( ch=fgetc(fp) ) )

;

do {

arry[i] = ch;

if ( '(' == ch )

flag = 1;

if ( 1 == flag && ')' == ch )

flag = 2;

ch = fgetc(fp);

++i;

if ( i > NAME - 1 )

return 0;

}while ( flag != 2 );

arry[i] = '\0';

/*printf("%s\n",arry); */

return 1;

}

/* 彩色代码由SciTE 生成 */

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有