Research portable Memory game | Исследовать портируемую игру Память
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

39 lignes
742B

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