1
0

wcmp.cpp 878 B

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