1
0

ncmp.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include "testlib.h"
  2. #include <sstream>
  3. using namespace std;
  4. string ending(long long x)
  5. {
  6. x %= 100;
  7. if (x / 10 == 1)
  8. return "th";
  9. if (x % 10 == 1)
  10. return "st";
  11. if (x % 10 == 2)
  12. return "nd";
  13. if (x % 10 == 3)
  14. return "rd";
  15. return "th";
  16. }
  17. string ltoa(long long n)
  18. {
  19. char c[32];
  20. sprintf(c, "%I64d", n);
  21. return c;
  22. }
  23. int main(int argc, char * argv[])
  24. {
  25. setName("compare ordered sequences of signed int%d numbers", 8 * sizeof(long long));
  26. registerTestlibCmd(argc, argv);
  27. int n = 0;
  28. string firstElems;
  29. while (!ans.seekEof())
  30. {
  31. n++;
  32. long long j = ans.readLong();
  33. long long p = ouf.readLong();
  34. if (j != p)
  35. quitf(_wa, "%d%s numbers differ - expected: '%I64d', found: '%I64d'", n, ending(n).c_str(), j, p);
  36. else
  37. if (n <= 5)
  38. {
  39. if (firstElems.length() > 0)
  40. firstElems += " ";
  41. firstElems += ltoa(j);
  42. }
  43. }
  44. if (n <= 5)
  45. {
  46. quitf(_ok, "%d number(s): \"%s\"", n, firstElems.c_str());
  47. }
  48. else
  49. quitf(_ok, "%d numbers", n);
  50. }