mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-27 03:36:20 +00:00
96d4a3ecf7
Due to historical reasons, the code is in subfolder "1". With SVN removal, we place the code back and remove the annoying "1" folder.
33 lines
778 B
C++
33 lines
778 B
C++
#include "testlib.h"
|
|
#include <cmath>
|
|
|
|
using namespace std;
|
|
|
|
const double EPS = 1E-6;
|
|
|
|
int main(int argc, char * argv[])
|
|
{
|
|
setName("compare two sequences of doubles, max absolute or relative error = %.7lf", EPS);
|
|
registerTestlibCmd(argc, argv);
|
|
|
|
int n = 0;
|
|
double j, p;
|
|
|
|
while (!ans.seekEof())
|
|
{
|
|
n++;
|
|
j = ans.readDouble();
|
|
p = ouf.readDouble();
|
|
if (!doubleCompare(j, p, EPS))
|
|
{
|
|
quitf(_wa, "%d%s numbers differ - expected: '%.7lf', found: '%.7lf', error = '%.7lf'",
|
|
n, englishEnding(n).c_str(), j, p, doubleDelta(j, p));
|
|
}
|
|
}
|
|
|
|
if (n == 1)
|
|
quitf(_ok, "found '%.7lf', expected '%.7lf', error '%.7lf'", p, j, doubleDelta(j, p));
|
|
|
|
quitf(_ok, "%d numbers", n);
|
|
}
|