Research portable Memory game | Исследовать портируемую игру Память
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.cpp 746B

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <map>
  2. #include <string>
  3. // L4: Function.
  4. std::map<int, int> memory_generateConstPlayfield(
  5. int n
  6. ) {
  7. std::map<int, int> idGroups;
  8. auto id = 0;
  9. for (auto gid = 0; gid < n; ++gid) {
  10. idGroups[id] = gid;
  11. id += 1;
  12. idGroups[id] = gid;
  13. id += 1;
  14. }
  15. return idGroups;
  16. }
  17. // L20: Test.
  18. std::string test_memory_generateConstPlayfield() {
  19. auto idGroups = memory_generateConstPlayfield(2);
  20. if (
  21. idGroups.size() == 4 &&
  22. idGroups[0] == 0 &&
  23. idGroups[1] == 0 &&
  24. idGroups[2] == 1 &&
  25. idGroups[3] == 1
  26. ) {
  27. return "OK: memory_generateConstPlayfield";
  28. }
  29. return "ERR: memory_generateConstPlayfield";
  30. }
  31. // L36: Run.
  32. int main() {
  33. printf("%s\n", test_memory_generateConstPlayfield().c_str());
  34. }