首页 > 其他分享 >[namespace hdk] diff.h

[namespace hdk] diff.h

时间:2024-07-25 20:39:52浏览次数:9  
标签:std false hdk namespace bool file diff true

Example

cth.txt

12345
54321
114514

hdk.txt

12345
54321
114514
#include"diff.h"
using namespace hdk::diff;
using namespace std;
int main(){
	fc("cth.txt","hdk.txt",true,true);
	//					   true:显示比较结果
	//							true:显示详细比较信息
	//返回值:相同=false 不同=true 
}

Result

fc cth.txt and hdk.txt
Compare: '12345' '12345'
Compare: '54321' '54321'
Compare: '114514' '114514'
File is equal.

Program

/*
 * diff.h
 * diff.h is a local C++ header file that 
 * used to compare and find the difference
 * of two file
 * 
 * Author : HaneDaniko
 * Create Time: 25/7/2024
 * 
 * To use this header, you must import this
 * file into you programme
**/
#ifndef HDK
#define HDK 0
#endif
#ifndef diff_h
#define diff_h 0
#endif
#include<string>
#include<cstring>
#include<cstdio>
#include<fstream>
#include<vector>
namespace hdk{
namespace diff{
	std::string a,b;
	bool fc(char file_A[],char file_B[],bool display=false,bool debug_mode=false){
		if(display){printf("fc %s and %s\n",file_A,file_B);}
		bool eofA=false,eofB=false;std::ifstream f1,f2;f1.open(file_A);f2.open(file_B);
		while(1){
			if(f1.eof()){eofA=true;}
			else{f1>>a;}
			if(f2.eof()){eofB=true;}
			if(eofA and eofB){if(display) printf("File is equal.\n"); return false;}
			else if(eofA or eofB){if(display) printf("Length is not equal.\n");return true;}
			else{f2>>b;}
			if(debug_mode){printf("Compare: '%s' '%s'\n",a.c_str(),b.c_str());}
			if(a!=b){if(display){
			printf("Find Difference: \n");
			printf("%s: %s\n",file_A,a.c_str());
			printf("%s: %s\n",file_B,b.c_str());}
			return true;
			}
		}
	}
	bool fc(std::string file_A,std::string file_B,bool display=false,bool debug_mode=false){
		char A[200001],B[200001];
		strcpy(A,file_A.c_str());
		strcpy(B,file_B.c_str());
		return fc(A,B,display,debug_mode);
	}
	template<typename T>
	std::vector<T>read(std::ifstream x){
		std::vector<T>an;T re;
		while(!x.eof()){x>>re;an.push_back(re);}
		return an;
	}
	template<typename read_out,typename func_out>
	bool fc(char file_A[],char file_B[],read_out(*read_t)(std::ifstream),func_out(*func)(read_out)){
		std::ifstream f1,f2;f1.open(file_A);f2.open(file_B);
		read_out A=read_t(f1);read_out B=read_t(f2);
		func_out x=func(A);func_out y=func(B);
		if(x==y) return false;else return true;
	}
}
}
/*--NAMESPACE HDK::DIFF  DIFF_H_--*/

标签:std,false,hdk,namespace,bool,file,diff,true
From: https://www.cnblogs.com/HaneDaCafe/p/18324107

相关文章

  • Enhancing Diffusion Models with Reinforcement Learning
    EnhancingDiffusionModelswithReinforcementLearningSep27,2023 | UncategorizedTL;DRTodaywe'regoingtotellyouallabout DRLX -ourlibraryforDiffusionReinforcementLearning!Releasedafewweeksago,DRLXisalibraryforscalabledist......
  • 《昇思 25 天学习打卡营第 18 天 | 扩散模型(Diffusion Models) 》
    《昇思25天学习打卡营第18天|扩散模型(DiffusionModels)》活动地址:https://xihe.mindspore.cn/events/mindspore-training-camp签名:Sam9029扩散模型(DiffusionModels)扩散模型概述扩散模型(DiffusionModels),特别是去噪扩散概率模型(DDPM),在图像、音频、视频生成领......
  • AIGC-DynamiCrafter: Animating Open-domain Images with Video Diffusion Priors-ECC
    论文:https://arxiv.org/pdf/2310.12190代码:https://github.com/Doubiiu/DynamiCrafter?tab=readme-ov-fileMOTIVATIONTraditionalimageanimationtechniquesmainlyfocusonanimatingnaturalsceneswithstochasticdynamics(e.g.cloudsandfluid)ordom......
  • [namespace hdk] 64位 bitset
    功能已重载运算符[](int)~()+(bitset)+(unsignedlonglong)+=(bitset)+=(unsignedlonglong)>==<>=<=(bitset\unsignedlonglong)<<>>max()min()已定义函数intsize()返回bitset大小intarray_size()返回bitset占用的unsigned_longlong......
  • Stable Diffusion原理与代码实例讲解
    StableDiffusion原理与代码实例讲解1.背景介绍1.1问题的由来在深入探讨StableDiffusion之前,让我们先了解其应用背景。StableDiffusion主要出现在扩散模型领域,特别是在生成对抗网络(GAN)、变分自编码器(VAE)以及自回归模型中。这些模型通常用于生成高质量的样本,例如图像......
  • Debian12 AMD 显卡 7900XT 安装使用 stable-diffusion-webui 笔记
    简介由于AMD官方没有提供Debian12的驱动和ROCM,只好安装Ubuntu20.04的驱动和ROCM,必要软件git和python3-venv。添加i386仓库sudodpkg--add-architecturei386&&\sudoaptupgrade-y&&\aptupgrade-y下载驱动安装程序到AMD官网下载Ubuntu20.04驱动......
  • 简单的 DiffSharp 示例
    如何将这个简单的PyTorch片段转换为DiffSharp?应该是类似的,但是很多功能没找到。#Definetensorswithrequires_grad=Truetotrackcomputationhistoryx=torch.tensor(2.0,requires_grad=True)y=torch.tensor(3.0,requires_grad=True)#Performacomputation......
  • 论文阅读——Integrated Diffusive Antenna Array of Low Backscattering
    文章目录摘要一、背景介绍二、天线结构A.缝隙天线B.低频扩散单元C.高频扩散单元D.集成设计三、验证总结论文来源:https://ieeexplore.ieee.org/document/10309141摘要文章提出了一种低雷达散射截面(RCS)的扩散天线阵列。作为示例,一个8×8的缝隙天线阵列与两个极......
  • Vue2中Diff算法解析
    Vue2中Diff算法解析import{compileToFunction}from'./compiler/index.js';import{patch,createElm}from'./vdom/patch';//1.创建第一个虚拟节点letvm1=newVue({data:{name:'hs'}});letrender1=compileToFunction('<div>{{nam......
  • Visible and Clear: Finding Tiny Objects in Difference Map
    VisibleandClear:FindingTinyObjectsinDifferenceMap论文链接:https://arxiv.org/abs/2405.11276项目链接:https://github.com/Hiyuur/SR-TOD(ECCV2024)Abstract微小目标检测是目标检测领域的关键问题之一。大多数通用检测器的性能在微小目标检测任务中显著下降......