Михаил Капелько 9 月之前
父節點
當前提交
e3b5ddea44
共有 8 個檔案被更改,包括 69 行新增30 行删除
  1. +0
    -16
      C++/Memory.Aux.cpp
  2. +0
    -8
      C++/main.cpp
  3. +0
    -0
      Memory.Test.cpp
  4. +0
    -0
      Memory.h
  5. +1
    -6
      gen-C++
  6. +2
    -0
      gen-JavaScript
  7. +35
    -0
      main.cpp
  8. +31
    -0
      main.js

+ 0
- 16
C++/Memory.Aux.cpp 查看文件

@@ -1,16 +0,0 @@
#include <map>
#include "Memory.h"

std::map<int, int> memory_generateConstPlayfield(
int n
) {
std::map<int, int> idGroups;
auto id = 0;
for (int gid = 0; gid < n; ++gid) {
idGroups[id] = gid;
id += 1;
idGroups[id] = gid;
id += 1;
}
return idGroups;
}

+ 0
- 8
C++/main.cpp 查看文件

@@ -1,8 +0,0 @@
#include "Memory.h"
#include <iostream>

int main() {
std::cout
<< test_memory_generateConstPlayfield()
<< std::endl;
}

C++/Memory.Test.cpp → Memory.Test.cpp 查看文件


C++/Memory.h → Memory.h 查看文件


+ 1
- 6
gen-C++ 查看文件

@@ -1,6 +1 @@
c++ -o test_memory_C++ \
-std=c++11 \
-IC++ \
C++/Memory.Aux.cpp \
C++/Memory.Test.cpp \
C++/main.cpp
c++ -o test_memory_C++ -std=c++11 main.cpp

+ 2
- 0
gen-JavaScript 查看文件

@@ -0,0 +1,2 @@
echo "node main.js" > test_memory_JavaScript
chmod +x test_memory_JavaScript

+ 35
- 0
main.cpp 查看文件

@@ -0,0 +1,35 @@
#include <map>
#include <string>

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;
}

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";
}

int main() {
printf("%s\n", test_memory_generateConstPlayfield().c_str());
}

+ 31
- 0
main.js 查看文件

@@ -0,0 +1,31 @@
function memory_generateConstPlayfield(
n
) {
var idGroups = {};
var id = 0;
for (let gid = 0; gid < n; ++gid) {
idGroups[id] = gid;
id += 1;
idGroups[id] = gid;
id += 1;
}

return idGroups;
}

function test_memory_generateConstPlayfield() {
let idGroups = memory_generateConstPlayfield(2)
if (
Object.keys(idGroups).length == 4 &&
idGroups[0] == 0 &&
idGroups[1] == 0 &&
idGroups[2] == 1 &&
idGroups[3] == 1
) {
return "OK: memory_generateConstPlayfield"
}

return "ERR: memory_generateConstPlayfield"
}

console.log(test_memory_generateConstPlayfield())

Loading…
取消
儲存