Difference between revisions of "Judge:Help/check.cpp"

From PEGWiki
Jump to: navigation, search
(Created page with "<syntaxhighlight lang="cpp> #include <iostream> #include <sstream> #include <fstream> #include <vector> using namespace std; vector<string> split(string& s) { vector<st...")
 
m
Line 1: Line 1:
<syntaxhighlight lang="cpp>
+
<syntaxhighlight lang="cpp">
 
#include <iostream>
 
#include <iostream>
 
#include <sstream>
 
#include <sstream>

Revision as of 00:31, 19 October 2011

#include <iostream>
#include <sstream>
#include <fstream>
#include <vector>
 
using namespace std;
 
vector<string> split(string& s)
{
        vector<string> vs;
        istringstream sin(s);
        while (sin >> s)
                vs.push_back(s); return vs;
}
 
bool Getline(ifstream& f, vector<string>& s)
{
        while (s.empty())
        {
                string str;
                if (!getline(f, str)) return false;
                s = split(str);
        }
        return true;
}
 
int main(int argv, char ** argc)
{
        ifstream F(argc[1]);
        ifstream G(argc[2]);
        bool a, b;
        vector<string> s, t;
        do
        {
                s = vector<string>();
                t = s;
                a = Getline(F, s);
                b = Getline(G, t);
                if (a ^ b) return 1;
                if (a && b && s != t) return 1;
        }
        while (a && b);
 
        return 0;
}