MCPcopy Create free account
hub / github.com/Project-LemonLime/Project_LemonLime / compareRealNumbers

Method compareRealNumbers

src/core/judgingthread.cpp:332–435  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

330}
331
332void JudgingThread::compareRealNumbers(const QString &contestantOutput) {
333 FILE *contestantOutputFile = fopen(contestantOutput.toLocal8Bit().data(), "r");
334
335 if (contestantOutputFile == nullptr) {
336 score = 0;
337 result = FileError;
338 message = tr(R"(Cannot open contestant's output file)");
339 return;
340 }
341
342 FILE *standardOutputFile = fopen(outputFile.toLocal8Bit().data(), "r");
343
344 if (standardOutputFile == nullptr) {
345 score = 0;
346 result = FileError;
347 message = tr(R"(Cannot open standard output file)");
348 fclose(contestantOutputFile);
349 return;
350 }
351
352 long double eps = 1;
353
354 for (int i = 0; i < task->getRealPrecision(); i++)
355 eps *= 0.1;
356
357 long double a = NAN;
358 long double b = NAN;
359 int nowRow = 1;
360
361 while (true) {
362 int cnt1 = fscanf(contestantOutputFile, "%Lf", &a);
363 int cnt2 = fscanf(standardOutputFile, "%Lf", &b);
364
365 char temps = fgetc(standardOutputFile);
366
367 if (cnt1 == 0) {
368 score = 0;
369 result = WrongAnswer;
370 message = tr(R"(On line %1, Invalid characters in contestant's output file)").arg(nowRow);
371 fclose(contestantOutputFile);
372 fclose(standardOutputFile);
373 return;
374 }
375
376 if (cnt2 == 0) {
377 score = 0;
378 result = FileError;
379 message = tr(R"(On line %1, Invalid characters in standard output file)").arg(nowRow);
380 fclose(contestantOutputFile);
381 fclose(standardOutputFile);
382 return;
383 }
384
385 if (cnt1 == EOF && cnt2 == EOF)
386 break;
387
388 if (cnt1 == EOF && cnt2 == 1) {
389 score = 0;

Callers

nothing calls this directly

Calls 1

getRealPrecisionMethod · 0.80

Tested by

no test coverage detected