提交 d1b7de83 创建 作者: 赵鹏翀's avatar 赵鹏翀

提交作业

上级 9a40964b
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
"label": "生成项目(make)", "label": "生成项目(make)",
"type": "shell", "type": "shell",
"windows": { "windows": {
"command": "cat \"${execPath}.tips\\env_tip.txt\" ; echo VSCode安装路径-${execPath} ; echo 正在生成项目 ; make" "command": "cat \"${execPath}.tips\\env_tip.txt\" ; echo VSCode安装路径-${execPath} ; echo 正在使用makefile文件生成项目 ; make"
}, },
"linux": { "linux": {
"command": "echo 正在生成项目 && make && echo 生成项目成功" "command": "echo 正在使用makefile文件生成项目 && make && echo 生成项目成功"
}, },
"args": [], "args": [],
"group": "build", "group": "build",
...@@ -57,10 +57,10 @@ ...@@ -57,10 +57,10 @@
"label": "清理项目(make clean)", "label": "清理项目(make clean)",
"type": "shell", "type": "shell",
"windows": { "windows": {
"command": "cat \"${execPath}.tips\\env_tip.txt\" ; echo VSCode安装路径-${execPath} ; echo 正在清理项目 ; make clean" "command": "cat \"${execPath}.tips\\env_tip.txt\" ; echo VSCode安装路径-${execPath} ; echo 正在使用makefile文件清理项目 ; make clean"
}, },
"linux": { "linux": {
"command": "echo 正在清理项目 && make clean && echo 清理项目成功" "command": "echo 正在使用makefile文件清理项目 && make clean && echo 清理项目成功"
}, },
"args": [], "args": [],
"group": "build", "group": "build",
......
...@@ -88,7 +88,7 @@ def compare_file(file1, file2, seqNum, caseCount, bIncludeCi): ...@@ -88,7 +88,7 @@ def compare_file(file1, file2, seqNum, caseCount, bIncludeCi):
print('文件路径不能为空:第一个文件的路径:{0}, 第二个文件的路径:{1} .'.format(file1, file2)) print('文件路径不能为空:第一个文件的路径:{0}, 第二个文件的路径:{1} .'.format(file1, file2))
sys.exit() sys.exit()
else: else:
print("正在比较文件 {0} 和 {1}".format(file1, file2), end=': ') print("正在比较标准答案输出文件 {0} 和用户编写的应用程序输出文件 {1}".format(file1, file2), end=': ')
if os.path.isfile(file1) and os.path.isfile(file2) and advanced_file_compare(file1, file2): if os.path.isfile(file1) and os.path.isfile(file2) and advanced_file_compare(file1, file2):
print("文件相同") print("文件相同")
...@@ -107,7 +107,8 @@ def compare_file(file1, file2, seqNum, caseCount, bIncludeCi): ...@@ -107,7 +107,8 @@ def compare_file(file1, file2, seqNum, caseCount, bIncludeCi):
outputPromptInfo(bIncludeCi, promptInfo, 1) outputPromptInfo(bIncludeCi, promptInfo, 1)
if seqNum == caseCount: if seqNum == caseCount:
print("恭喜你,通过了所有的测试!") promptInfo = "恭喜你通过了所有测试!"
outputPromptInfo(bIncludeCi, promptInfo, 1)
returnVal = 1 returnVal = 1
return returnVal return returnVal
...@@ -163,22 +164,17 @@ def outputPromptInfo(bIncludeCi, promptInfo, color): ...@@ -163,22 +164,17 @@ def outputPromptInfo(bIncludeCi, promptInfo, color):
if __name__ == "__main__": if __name__ == "__main__":
if bIncludeCi == False:
print("开发环境中的 Python 解释器版本号:" + platform.python_version())
print()
compResultFile = "result_comparation.html" compResultFile = "result_comparation.html"
if os.path.isfile(compResultFile): if os.path.isfile(compResultFile):
os.remove(compResultFile) os.remove(compResultFile)
promptInfo = "正在使用make生成项目" promptInfo = "正在使用 makefile 文件生成项目"
outputPromptInfo(bIncludeCi, promptInfo, 1) outputPromptInfo(bIncludeCi, promptInfo, 1)
execResult = os.system("make") execResult = os.system("make")
if execResult != 0: if execResult != 0:
errorInfo = "应用程序异常,返回值:{0}。".format(execResult) errorInfo = "生成项目失败"
outputPromptInfo(bIncludeCi, errorInfo, 2) outputPromptInfo(bIncludeCi, errorInfo, 2)
exit(1) exit(1)
else: else:
...@@ -186,12 +182,12 @@ if __name__ == "__main__": ...@@ -186,12 +182,12 @@ if __name__ == "__main__":
if not os.path.isfile("output1.txt"): if not os.path.isfile("output1.txt"):
score = 100 score = 100
if bIncludeCi: if bIncludeCi:
promptInfo = "项目生成成功" promptInfo = "生成项目成功"
outputPromptInfo(bIncludeCi, promptInfo, 1) outputPromptInfo(bIncludeCi, promptInfo, 1)
promptInfo = "exec-score {0}".format(score) promptInfo = "exec-score {0}".format(score)
print(promptInfo) print(promptInfo)
else: else:
promptInfo = "项目生成成功, 分数 {0}".format(score) promptInfo = "生成项目成功, 分数 {0}".format(score)
outputPromptInfo(bIncludeCi, promptInfo, 1) outputPromptInfo(bIncludeCi, promptInfo, 1)
...@@ -245,9 +241,6 @@ if __name__ == "__main__": ...@@ -245,9 +241,6 @@ if __name__ == "__main__":
print("使用的标准输入文件是 intput{0}.txt。\n标准答案输出文件 output{1}.txt(左边)与用户编写的应用程序输出文件 user_output{2}.txt(右边)的比较结果:".format(seqNum, seqNum, seqNum)) print("使用的标准输入文件是 intput{0}.txt。\n标准答案输出文件 output{1}.txt(左边)与用户编写的应用程序输出文件 user_output{2}.txt(右边)的比较结果:".format(seqNum, seqNum, seqNum))
runCommand = "diff {0} {1} -b -B -y -i -W 100".format(outputFile, useroutputFile) runCommand = "diff {0} {1} -b -B -y -i -W 100".format(outputFile, useroutputFile)
execResult = os.system(runCommand) execResult = os.system(runCommand)
#if execResult != 0:
# errorInfo = "输出结果比较异常,返回值:{0}。".format(execResult)
# outputPromptInfo(bIncludeCi, errorInfo, 2)
else: else:
promptInfo = "查看文件比较结果可帮助你查找验证失败的原因。方法是:\n选择 View 菜单中的 Explorer 打开文件列表,右键点击 result_comparation.html 文件,在弹出的菜单中选择 Open Preview" promptInfo = "查看文件比较结果可帮助你查找验证失败的原因。方法是:\n选择 View 菜单中的 Explorer 打开文件列表,右键点击 result_comparation.html 文件,在弹出的菜单中选择 Open Preview"
outputPromptInfo(bIncludeCi, promptInfo, 2) outputPromptInfo(bIncludeCi, promptInfo, 2)
......
void fun()
{
int a, b;
b = a;
}
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
void fun();
int main() int main()
{ {
int x, y; int x, y;
int *p = malloc(8); int *p = malloc(8);
fun();
scanf("%d", &x); scanf("%d", &x);
......
...@@ -16,9 +16,11 @@ CC = gcc ...@@ -16,9 +16,11 @@ CC = gcc
CFLAGS = -g -w -fmax-errors=10 -std=c99 -fsigned-char -I${DIR_INC} CFLAGS = -g -w -fmax-errors=10 -std=c99 -fsigned-char -I${DIR_INC}
${BIN_TARGET}:${OBJ} ${BIN_TARGET}:${OBJ}
@echo --- build executable file: $@
$(CC) $(OBJ) -o $@ $(CC) $(OBJ) -o $@
${DIR_OBJ}/%.o:${DIR_SRC}/%.c ${DIR_OBJ}/%.o:${DIR_SRC}/%.c
@echo --- build object file: $@
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
RM = @echo 无法识别的平台。无法删除文件 RM = @echo 无法识别的平台。无法删除文件
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论