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

  • 相关阅读:
    cqyz oj | 单峰排列
    cqyz oj/uva 548 | 二叉树
    cqyz oj | 树网的核 | 树的直径
    cqyz oj | 树上的询问 | 最近公共祖先
    cqyz oj | 循环逆序对 | 逆序对 | 树状数组
    cqyz oj | 潜水比赛 | 贪心
    YOLO v3 & Pascal VOC数据集
    太阳爆发分类
    PPT制作
    anaconda
  • 原文地址:https://www.cnblogs.com/byfei/p/3112281.html
Copyright © 2011-2022 走看看