Last active
December 15, 2017 01:22
-
-
Save you74674/0675569c88472c95a8f9716ea6421387 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<cstdio> | |
#include<iostream> | |
#include<fstream> | |
using namespace std; | |
string exec(const char* cmd){ | |
string ret; | |
char buf[128]; | |
FILE *f=popen(cmd, "r"); | |
while(!feof(f)) | |
if(fgets(buf, 128, f) != NULL) | |
ret += buf; | |
pclose(f); | |
return ret; | |
} | |
int main(int argc, char** argv) | |
{ | |
string f1=argv[1];//original | |
string f2=argv[2];//ncr | |
string f3=argv[3];//answer | |
string cmd="diff -Z -B --strip-trailing-cr -q "+f2+" "+f3; | |
ifstream f1s(f1.c_str()), f2s(f2.c_str()); | |
if(f1s && f2s) | |
{ | |
string ret=exec(cmd.c_str()); | |
if(ret.length()==0)//ncr is the same as answer | |
{ | |
cmd="cp "+f3+" "+f1; | |
exec(cmd.c_str()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment