• 读取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");
    }

  • 相关阅读:
    【转】size_t和ssize_t
    WCF订票系统DEMO
    VS2008显示解决方案的方法
    一些好用的开源控件
    SQL 的Over 子句
    Sql2005高效分页语句
    使用winform的showdialog小心内存泄漏
    字符串连接类(Javascript)
    SharpZipLib 的使用
    浅谈持久化
  • 原文地址:https://www.cnblogs.com/byfei/p/3112281.html
Copyright © 2020-2023  润新知