Research portable Memory game | Исследовать портируемую игру Память
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

7 个月前
7 个月前
7 个月前
7 个月前
7 个月前
7 个月前
7 个月前
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. }