fcmp.cpp 1015 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "testlib.h"
  2. #include <string>
  3. #include <vector>
  4. #include <sstream>
  5. using namespace std;
  6. string ending(int x)
  7. {
  8. x %= 100;
  9. if (x / 10 == 1)
  10. return "th";
  11. if (x % 10 == 1)
  12. return "st";
  13. if (x % 10 == 2)
  14. return "nd";
  15. if (x % 10 == 3)
  16. return "rd";
  17. return "th";
  18. }
  19. int main(int argc, char * argv[])
  20. {
  21. setName("compare files as sequence of lines");
  22. registerTestlibCmd(argc, argv);
  23. std::string strAnswer;
  24. int n = 0;
  25. while (!ans.eof())
  26. {
  27. std::string j = ans.readString();
  28. if (j == "" && ans.eof())
  29. break;
  30. strAnswer = j;
  31. std::string p = ouf.readString();
  32. n++;
  33. quitif(j != p, _wa, "%d%s lines differ - expected: '%s', found: '%s'",
  34. n, ending(n).c_str(), __testlib_part(j).c_str(), __testlib_part(p).c_str());
  35. }
  36. quitif(n == 1 && strAnswer.length() <= 128, _ok, "%s", strAnswer.c_str());
  37. quitf(_ok, "%d lines", n);
  38. }