hcmp.cpp 824 B

1234567891011121314151617181920212223242526272829
  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. quitif(!isNumeric(ja), _fail, "%s is not valid integer", __testlib_part(ja).c_str());
  16. quitif(!ans.seekEof(), _fail, "expected exactly one token in the answer file");
  17. quitif(!isNumeric(pa), _pe, "%s is not valid integer", __testlib_part(pa).c_str());
  18. quitif(ja != pa, _wa, "expected %s, found %s", __testlib_part(ja).c_str(), __testlib_part(pa).c_str());
  19. quitf(_ok, "answer is %s", __testlib_part(ja).c_str());
  20. }