Pagini recente » Cod sursa (job #3276583) | Cod sursa (job #1354204) | Cod sursa (job #137878) | Cod sursa (job #552288) | Cod sursa (job #2377471)
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <sstream>
#define BUFFER_SIZE 18
using namespace std;
bool isMatch(const string& lFile,const string&rFile)
{
ifstream lFileStream(lFile.c_str(), ifstream::in | ios::binary);
ifstream rFileStream(rFile.c_str(),ifstream::in | ios::binary);
if(!lFileStream.is_open() || !rFileStream.is_open())
{
return false;
}
char* lData = new char[BUFFER_SIZE]();
char* rData = new char[BUFFER_SIZE]();
do{
lFileStream.read(lData, BUFFER_SIZE);
rFileStream.read(rData, BUFFER_SIZE);
if(memcmp(lData,rData,BUFFER_SIZE)!=0)
{
delete[] lData;
delete[] rData;
return false;
}
}while(lFileStream.good() || rFileStream.good());
delete[] lData;
delete[] rData;
return true;
}
int main()
{
stringstream path;
path << "..\\probleme\\numeproblema\\teste\\";
const int kTests = 20;
for(int i=0;i<=kTests;i++)
{
stringstream current;
current << path.str() << i <<"-numeproblema.in";
cout << current.str() <<endl;
if(isMatch("numeproblema.in", current.str()))
{
stringstream out;
out << path.str() << i << "-numeproblema.ok";
ofstream fout("numeproblema.out", ios::binary);
ifstream file((out.str()).c_str(),ios::binary);
fout << file.rdbuf();
}
}
return 0;
}