Михаил Капелько 1 月之前
父節點
當前提交
050eecea53
共有 3 個文件被更改,包括 18 次插入5 次删除
  1. +6
    -1
      main.cpp
  2. +6
    -2
      main.js
  3. +6
    -2
      main.swift

+ 6
- 1
main.cpp 查看文件

@@ -1,6 +1,8 @@
#include <map> #include <map>
#include <string> #include <string>


// L4: Function.

std::map<int, int> memory_generateConstPlayfield( std::map<int, int> memory_generateConstPlayfield(
int n int n
) { ) {
@@ -15,6 +17,8 @@ std::map<int, int> memory_generateConstPlayfield(
return idGroups; return idGroups;
} }


// L20: Test.

std::string test_memory_generateConstPlayfield() { std::string test_memory_generateConstPlayfield() {
auto idGroups = memory_generateConstPlayfield(2); auto idGroups = memory_generateConstPlayfield(2);
if ( if (
@@ -26,10 +30,11 @@ std::string test_memory_generateConstPlayfield() {
) { ) {
return "OK: memory_generateConstPlayfield"; return "OK: memory_generateConstPlayfield";
} }

return "ERR: memory_generateConstPlayfield"; return "ERR: memory_generateConstPlayfield";
} }


// L36: Run.

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

+ 6
- 2
main.js 查看文件

@@ -1,6 +1,8 @@






// L4: Function.

function memory_generateConstPlayfield( function memory_generateConstPlayfield(
n n
) { ) {
@@ -12,10 +14,11 @@ function memory_generateConstPlayfield(
idGroups[id] = gid; idGroups[id] = gid;
id += 1; id += 1;
} }

return idGroups; return idGroups;
} }


// L20: Test.

function test_memory_generateConstPlayfield() { function test_memory_generateConstPlayfield() {
let idGroups = memory_generateConstPlayfield(2) let idGroups = memory_generateConstPlayfield(2)
if ( if (
@@ -27,8 +30,9 @@ function test_memory_generateConstPlayfield() {
) { ) {
return "OK: memory_generateConstPlayfield" return "OK: memory_generateConstPlayfield"
} }

return "ERR: memory_generateConstPlayfield" return "ERR: memory_generateConstPlayfield"
} }


// L36: Run.

console.log(test_memory_generateConstPlayfield()) console.log(test_memory_generateConstPlayfield())

+ 6
- 2
main.swift 查看文件

@@ -1,6 +1,8 @@






// L4: Function

func memory_generateConstPlayfield( func memory_generateConstPlayfield(
_ n: Int _ n: Int
) -> [Int: Int] { ) -> [Int: Int] {
@@ -12,10 +14,11 @@ func memory_generateConstPlayfield(
idGroups[id] = gid idGroups[id] = gid
id += 1 id += 1
} }

return idGroups return idGroups
} }


// L20: Test.

func test_memory_generateConstPlayfield() -> String { func test_memory_generateConstPlayfield() -> String {
let idGroups = memory_generateConstPlayfield(2) let idGroups = memory_generateConstPlayfield(2)
if ( if (
@@ -27,8 +30,9 @@ func test_memory_generateConstPlayfield() -> String {
) { ) {
return "OK: memory_generateConstPlayfield" return "OK: memory_generateConstPlayfield"
} }

return "ERR: memory_generateConstPlayfield" return "ERR: memory_generateConstPlayfield"
} }


// L36: Run.

print(test_memory_generateConstPlayfield()) print(test_memory_generateConstPlayfield())

Loading…
取消
儲存