• 比较两个文件的数字差异


    #include <m_tools.h>
    #include <stdio.h>
    #include <assert.h>
    #include <vector>
    #include <string>
    int main(int argc , char ** argv)
    {
    
        assert( argc>=3 );
        FILE* file1, *file2;
    
        printf( "open file %s , %s ...
    ", argv[1], argv[2] );
    
        file1 = fopen(argv[1],"r");
        file2 = fopen(argv[2], "r");
    
        if (!file1 || !file2) {
            printf("open files fail 
    ");
            getchar();
        }
    
        char str1[1024];
        char str2[1024];
        int linecount = 0;
        double d_max = 0;
    
        while (!feof(file1) && !feof(file2)) {
            ++linecount;
            fgets(str1, 1024, file1);
            fgets(str2, 1024, file2);  
            std::vector<float> nums1 = search_number_f( std::string( str1 ) );
            std::vector<float> nums2 = search_number_f(std::string(str2));
    
            int sz = __min(nums1.size(), nums2.size());
            for (int i = 0; i != sz; ++i) {
                double d = fabs(nums1[i]-nums2[i]);
                if (d > d_max) {
                    printf( "find more different number %.8f, %.8f , diff=%.8f line=%d
    ",nums1[i], nums2[i], d, linecount);
                    d_max = d;
                }
            }
        }
    
        fclose(file1);
        fclose(file2);
        printf("done
    ");
        getchar();
    }
  • 相关阅读:
    [论文复现笔记]Im2Struct
    深度学习踩坑
    Matlab问题汇总
    Linux网络服务
    探索Blender
    [每日挖坑]20200728
    Ubuntu重启之后显卡挂了
    3D视觉知识点
    [每日挖坑]20200727
    遥感影像相关知识
  • 原文地址:https://www.cnblogs.com/luoyinjie/p/12809888.html
Copyright © 2020-2023  润新知