hcmp.cpp 839 B

1234567891011121314151617181920212223242526272829303132
  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. return pnum.matches(p);
  7. }
  8. int main(int argc, char *argv[]) {
  9. setName("compare two signed huge integers");
  10. registerTestlibCmd(argc, argv);
  11. string ja = ans.readWord();
  12. string pa = ouf.readWord();
  13. if (!isNumeric(ja))
  14. quitf(_fail, "%s is not a valid integer", compress(ja).c_str());
  15. if (!ans.seekEof())
  16. quitf(_fail, "expected exactly one token in the answer file");
  17. if (!isNumeric(pa))
  18. quitf(_pe, "%s is not a valid integer", compress(pa).c_str());
  19. if (ja != pa)
  20. quitf(_wa, "expected '%s', found '%s'", compress(ja).c_str(), compress(pa).c_str());
  21. quitf(_ok, "answer is '%s'", compress(ja).c_str());
  22. }