yesno.cpp 792 B

1234567891011121314151617181920212223242526272829
  1. #include "testlib.h"
  2. std::string upper(std::string sa)
  3. {
  4. for (size_t i = 0; i < sa.length(); i++)
  5. if ('a' <= sa[i] && sa[i] <= 'z')
  6. sa[i] = sa[i] - 'a' + 'A';
  7. return sa;
  8. }
  9. int main(int argc, char * argv[])
  10. {
  11. setName("YES or NO (case insensetive)");
  12. registerTestlibCmd(argc, argv);
  13. std::string ja = upper(ans.readWord());
  14. std::string pa = upper(ouf.readWord());
  15. if (pa != "YES" && pa != "NO")
  16. quitf(_pe, "YES or NO expected, but %s found", pa.c_str());
  17. if (ja != "YES" && ja != "NO")
  18. quitf(_fail, "YES or NO expected in answer, but %s found", ja.c_str());
  19. if (ja != pa)
  20. quitf(_wa, "expected %s, found %s", ja.c_str(), pa.c_str());
  21. quitf(_ok, "answer is %s", ja.c_str());
  22. }