1
0

hcmp.cpp 856 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include "testlib.h"
  2. #include <string>
  3. using namespace std;
  4. pattern pnum("0|-?[1-9][0-9]*");
  5. bool isNumeric(const string& p)
  6. {
  7. return pnum.matches(p);
  8. }
  9. int main(int argc, char * argv[])
  10. {
  11. setName("compare two signed huge integers");
  12. registerTestlibCmd(argc, argv);
  13. string ja = ans.readWord();
  14. string pa = ouf.readWord();
  15. if (!isNumeric(ja))
  16. quitf(_fail, "%s is not a valid integer", compress(ja).c_str());
  17. if (!ans.seekEof())
  18. quitf(_fail, "expected exactly one token in the answer file");
  19. if (!isNumeric(pa))
  20. quitf(_pe, "%s is not a valid integer", compress(pa).c_str());
  21. if (ja != pa)
  22. quitf(_wa, "expected '%s', found '%s'", compress(ja).c_str(), compress(pa).c_str());
  23. quitf(_ok, "answer is '%s'", compress(ja).c_str());
  24. }