uhcmp.cpp 789 B

12345678910111213141516171819202122232425262728293031323334
  1. #include "testlib.h"
  2. #include <string>
  3. using namespace std;
  4. bool isNumeric(string p)
  5. {
  6. for (int i = 0; i < p.length(); i++)
  7. if (p[i] < '0' || p[i] > '9')
  8. return false;
  9. return p.length() > 0 && (p.length() == 1 || p[0] != '0');
  10. }
  11. int main(int argc, char * argv[])
  12. {
  13. setName("compare two unsigned huge integers");
  14. registerTestlibCmd(argc, argv);
  15. string ja = ans.readWord();
  16. string pa = ouf.readWord();
  17. if (!isNumeric(ja))
  18. quitf(_fail, "%s is not numeric", ja.c_str());
  19. if (!isNumeric(pa))
  20. quitf(_pe, "%s is not numeric", pa.c_str());
  21. if (ja != pa)
  22. quitf(_wa, "expected %s, found %s", ja.c_str(), pa.c_str());
  23. quitf(_ok, "answer is %s", ja.c_str());
  24. }