zoukankan      html  css  js  c++  java
  • 读取txt数据

     

    #include <stdio.h>
    #include <stdlib.h>
    #include <iostream>
    #include <set>
    #define MAXSIZE 100000
    using namespace std;

    set<int> OldRole12_31;
    set<int> OldRole1_1;
    set<int> OldRole1_2;

    void main()
    {
     FILE *fp12_31;
        FILE *fp1_1;
     FILE *fp1_2;

     if ( (fp12_31 = fopen( "d:\\OldRoleID12-31.txt", "r" )) == NULL )
      printf("ERROR!\n");
        if ( (fp1_1 = fopen( "d:\\OldRoleID1-1.txt", "r" )) == NULL )
      printf("ERROR!\n");
     if ( (fp1_2 = fopen( "d:\\OldRoleID1-2.txt", "r" )) == NULL )
      printf("ERROR!\n");
     
     int OldRoleID;
        int i=0;
        while ( !feof(fp12_31) && i!=MAXSIZE )
        {
            fscanf( fp12_31, "%d ", &OldRoleID );
      OldRole12_31.insert(OldRoleID);
            i++;
        }
     cout<<i<<endl;
     i=0;
     int j=0;
     while ( !feof(fp1_1) && i!=MAXSIZE)
        {
            fscanf( fp1_1, "%d ", &OldRoleID );
      if(OldRole12_31.find(OldRoleID)!=OldRole12_31.end())
      {
       OldRole1_1.insert(OldRoleID);
       j++;
      }
            i++;
        }
     cout<<j<<endl;
     i=0;
     j=0;
     while ( !feof(fp1_2) && i!=MAXSIZE)
        {
            fscanf( fp1_2, "%d ", &OldRoleID );
      if(OldRole1_1.find(OldRoleID)!=OldRole1_1.end())
      {
       j++;
      }
            i++;
        }
     cout<<j<<endl;
        fclose( fp1_1 );
        fclose( fp1_2 );
     fclose( fp12_31 );
        system("PAUSE");
    }

  • 相关阅读:
    服务器图片等资源在8080端口保存
    thinkphp 3.2.1 URL 大小写问题 下面有具体说明
    linux samba smb 在客户端无法连接使用
    php连接redis服务
    服务器死机 导致 mongo 挂掉
    同一个页面引用不同版本jquery库
    CSS3阴影 box-shadow的使用和技巧总结
    php 中使用正则
    Hbase-1.1.1-java API
    hive1.2.1问题集锦
  • 原文地址:https://www.cnblogs.com/byfei/p/3112281.html
Copyright © 2011-2022 走看看