/*
 * 本程序 使用 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 生成 */

qq群 发言统计for tc相关推荐

  1. 原创:QQ群发言统计

    源码下载 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; ...

  2. python 实现QQ群接龙统计未接龙成员名单

    在学校当班长有时候需要使用QQ群接龙统计,但这个该死的QQ群接龙没法自定义接龙格式而且设置填写人名单还挺麻烦,对我统计未接龙成员名单造成了挺大的困扰(毕竟不想麻烦同学在名字前加个学号什么的,就只让他们 ...

  3. python 写脚本 获取qq好友地理位置_Python获取统计自己的qq群成员信息的方法

    这篇文章主要介绍了Python获取统计自己的qq群成员信息的方法,本文分步骤给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下 首先说明一下需要使用的工具以及技术:python3 + ...

  4. python抓取qq群消息_Python获取统计自己的qq群成员信息的方法

    首先说明一下需要使用的工具以及技术:python3 + selenium selenium安装方法:pip install selenium 前提:获取自己的qq群成员信息,自己必须是群主或者管理员, ...

  5. qq群30天发言人数

    一个亲友小群,群等级降到了2级,然后一个小伙伴不辞辛劳地跳出来跟大家唠嗑,想提升群等级. 仔细看了下群等级的规则 机智的我怀疑是群主没给群充值,其他人无法通过入群申请,所以群等级下降了. 证实下自己的 ...

  6. 第一次QQ群视频教育有感

    标题:第一次QQ群视频教育有感 作者:丁又专, 时间:2014.08.16 教育的目的:启发学生心智,发现个人优势,激发探索欲望. 今天早上看到 中国大学MOOC<文献管理与信息分析>(h ...

  7. 一梦江湖费六年——QQ群聊天分析

    本文结构: 一.那些年我们加过的QQ群 二.数据读入和整理(一)--来自蓝翔的挖掘机 二.数据读入和整理(二)--你不知道的事 三.聊天宏观(1)--寤寐思服 三.聊天宏观(2)日月篇 三.聊天宏观( ...

  8. 使用 R 语言挖掘 QQ 群聊天记录

    1.获取数据 从 QQ 消息管理器中导出消息记录,保存的文本类型选择 txt 文件.这里获取的是某群从 2016-04-18 到 2016-05-07 期间的聊天记录,记录样本如下所示. 消息记录(此 ...

  9. 新建QQ群-欢迎加入

    新建一个QQ群   对flex有兴趣的朋友 可以加入 第3群: 48815811 第4群: 21995448 第5群: 53081329 确信信息: flex 为了创造更好的学习Flex气氛,群内特设 ...

最新文章

  1. 高并发大流量专题---8、动态语言的并发处理
  2. mac微软雅黑字体_【字体字重】常见设计稿字体对应字重
  3. c语言复制的代码不能运行,刚学C语言,在Linux下写的代码能正常编译,复制到VC下就无法运行...
  4. android 访问https服务器
  5. java编写螺旋矩阵讲解_Java如何实现螺旋矩阵 Java实现螺旋矩阵代码实例
  6. redis事务的简单介绍
  7. 数据库系统实训——实验五——存储过程
  8. 基于单片机智能药盒控制系统设计(含论文)
  9. 网址导航7654推广
  10. Latex公式编辑快速入门
  11. css盒模型(标准模式和怪异模式)
  12. 做独一无二的自己,颜宁西湖大学问答全记录
  13. STM32系统定时器闪烁LED灯
  14. oracle client 是什么,Oracle数据库与客户端有什么区别
  15. 第二人生的源码分析(六十四)类LLCurlEasyRequest实现Http请求
  16. 蓝牙耳机哪个品牌经济实惠?价格便宜音质好的蓝牙耳机推荐
  17. html 手机ar,vr与ar技术的区别有哪些
  18. android气泡组件,Android 聊天气泡
  19. 【Java】 杨辉三角 二维数组打印杨辉三角
  20. 深度Deepin系统关机或重启的时候提示unattended upgrades shutdown的解决办法

热门文章

  1. Redis 根据IPv6地址查询全球国家、省、市位置信息方案
  2. 不入门级代码教程(仅供参考)
  3. C语言实现MD5加密算法
  4. 问道科技产业新变局,2022「甲子引力」年终盛典圆满举办|甲子引力
  5. 赵栋 java_赵栋 201771010137 《面向对象程序设计(java)》
  6. javaweb之ajax
  7. 让2010成为我的新纪元
  8. EOS智能合约开发(四)EOS智能合约部署及调试(附编程示例)
  9. SQL 语句多表联查
  10. 马来西亚理科大学计算机专业雅思,马来西亚理科大学本科雅思成绩要求