ncmp.cpp 745 B

12345678910111213141516171819202122232425262728293031323334353637
  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 ordered sequences of signed int%d's", 8 * sizeof(int));
  19. registerTestlibCmd(argc, argv);
  20. int n = 0;
  21. while (!ans.seekEof())
  22. {
  23. n++;
  24. int j = ans.readInt();
  25. int p = ouf.readInt();
  26. if (j != p)
  27. quitf(_wa, "%d%s numbers differ - expected: '%d', found: '%d'", n, ending(n).c_str(), j, p);
  28. }
  29. quitf(_ok, "%d numbers", n);
  30. }