diff --git "a/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/4.\351\242\204\345\244\204\347\220\206\345\231\250/2.#include\346\214\207\344\273\244/calc.h" "b/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/4.\351\242\204\345\244\204\347\220\206\345\231\250/2.#include\346\214\207\344\273\244/calc.h" new file mode 100644 index 0000000000000000000000000000000000000000..ad31e15acd4ade5a8e211789df8c6433191b10b4 --- /dev/null +++ "b/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/4.\351\242\204\345\244\204\347\220\206\345\231\250/2.#include\346\214\207\344\273\244/calc.h" @@ -0,0 +1,23 @@ +// 标题: 定义一个 C语言的头文件 +// 描述: 头文件可以被其他文件代码通过 #include "xxx.h" +// 导入,下面哪个选项的头文件的实现正确。 + +#ifndef CALC_H +#define CALC_H + +int calc(char op, int x, int y) { + switch (op) { + case '+': + return x + y; + case '-': + return x - y; + case '*': + return x * y; + case '/': + return x / y; + default: + return 0; + } +} + +#endif \ No newline at end of file diff --git "a/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/4.\351\242\204\345\244\204\347\220\206\345\231\250/2.#include\346\214\207\344\273\244/calc.json" "b/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/4.\351\242\204\345\244\204\347\220\206\345\231\250/2.#include\346\214\207\344\273\244/calc.json" new file mode 100644 index 0000000000000000000000000000000000000000..f258bec87b5caedd2186ff90e69c328925b9c914 --- /dev/null +++ "b/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/4.\351\242\204\345\244\204\347\220\206\345\231\250/2.#include\346\214\207\344\273\244/calc.json" @@ -0,0 +1,18 @@ +{ + "type": "code_options", + "author": "幻灰龙", + "source": "calc.h", + "multiline":[ + { + "#ifndef CALC_H": "", + "#define CALC_H": "", + "#endif": "" + }, + { + "#define CALC_H": "" + }, + { + "#ifndef CALC_H": "" + } + ] +} \ No newline at end of file diff --git "a/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/4.\351\242\204\345\244\204\347\220\206\345\231\250/2.#include\346\214\207\344\273\244/calc_test.c" "b/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/4.\351\242\204\345\244\204\347\220\206\345\231\250/2.#include\346\214\207\344\273\244/calc_test.c" new file mode 100644 index 0000000000000000000000000000000000000000..cdc3d49fdb61c7b3cb31c0fd712240a9ab173416 --- /dev/null +++ "b/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/4.\351\242\204\345\244\204\347\220\206\345\231\250/2.#include\346\214\207\344\273\244/calc_test.c" @@ -0,0 +1,10 @@ +// 标题: 简易四则运算 +// 描述: 假设"calc.h"和本文件在同一个目录下,计算 (1+2)*(2-1)/2 + +#include "calc.h" +#include + +int main(int argc, char **args) { + printf("%d", calc('/', calc('*', calc('+', 1, 2), calc('-', 2, 1)), 2)); + return 0; +} \ No newline at end of file diff --git "a/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/4.\351\242\204\345\244\204\347\220\206\345\231\250/2.#include\346\214\207\344\273\244/calc_test.json" "b/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/4.\351\242\204\345\244\204\347\220\206\345\231\250/2.#include\346\214\207\344\273\244/calc_test.json" new file mode 100644 index 0000000000000000000000000000000000000000..0aa413c8c3b79195bc41ef0cf4729718770d933e --- /dev/null +++ "b/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/4.\351\242\204\345\244\204\347\220\206\345\231\250/2.#include\346\214\207\344\273\244/calc_test.json" @@ -0,0 +1,16 @@ +{ + "type": "code_options", + "author": "幻灰龙", + "source": "calc_test.c", + "multiline":[ + { + "#include \"calc.h\"":"#include " + }, + { + "#include \"calc.h\"":"using \"calc.h\"" + }, + { + "#include \"calc.h\"":"#include(\"calc.h\")" + } + ] +} \ No newline at end of file diff --git "a/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/4.\351\242\204\345\244\204\347\220\206\345\231\250/2.#include\346\214\207\344\273\244/config.json" "b/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/4.\351\242\204\345\244\204\347\220\206\345\231\250/2.#include\346\214\207\344\273\244/config.json" index 1def284e5fc138be0c0c5c215485f10457bddd2c..d26f4d18e048055e65e760f3369f60b345cfb77c 100644 --- "a/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/4.\351\242\204\345\244\204\347\220\206\345\231\250/2.#include\346\214\207\344\273\244/config.json" +++ "b/data/3.C\350\257\255\350\250\200\351\253\230\351\230\266/4.\351\242\204\345\244\204\347\220\206\345\231\250/2.#include\346\214\207\344\273\244/config.json" @@ -6,5 +6,8 @@ "C语言" ], "children": [], - "export": [] + "export": [ + "calc.json", + "calc_test.json" + ] } \ No newline at end of file