|
- #include <map>
- #include <string>
-
- // L4: Function.
-
- std::map<int, int> memory_generateConstPlayfield(
- int n
- ) {
- std::map<int, int> idGroups = { };
- auto id = 0;
- for (auto gid = 0; gid < n; ++gid) {
- idGroups[id] = gid;
- id += 1;
- idGroups[id] = gid;
- id += 1;
- }
- return idGroups;
- }
-
- // L20: Test.
-
- std::string test_memory_generateConstPlayfield() {
- auto idGroups = memory_generateConstPlayfield(2);
- if (
- idGroups.size() == 4 &&
- idGroups[0] == 0 &&
- idGroups[1] == 0 &&
- idGroups[2] == 1 &&
- idGroups[3] == 1
- ) {
- return "OK: memory_generateConstPlayfield";
- }
- return "ERR: memory_generateConstPlayfield";
- }
-
- // L36: Run.
-
- int main() {
- printf("%s\n", test_memory_generateConstPlayfield().c_str());
- }
|