fcmp.cpp 1010 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. if (j != p)
  34. quitf(_wa, "%d%s lines differ - expected: '%s', found: '%s'", n, ending(n).c_str(), j.c_str(), p.c_str());
  35. }
  36. if (n == 1 && strAnswer.length() <= 128)
  37. quitf(_ok, "%s", strAnswer.c_str());
  38. quitf(_ok, "%d lines", n);
  39. }