【置顶】考试注意事项


写一些考场上可能用得到、有帮助的东西。如有不足,欢迎提出!

Linux:考场 gedit 外部工具配置文件

1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/sh
# C++ Compile
FILENAME="$GEDIT_CURRENT_DOCUMENT_DIR/$GEDIT_CURRENT_DOCUMENT_NAME"
PROGNAME="$GEDIT_CURRENT_DOCUMENT_DIR/${GEDIT_CURRENT_DOCUMENT_NAME%.*}"

g++ "$FILENAME" -o "$PROGNAME" -Wall -Wextra -fsanitize=address

if [ $? -eq 0 ]; then
echo "Compile Succeed!"
else
echo "Compile Failed!"
fi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh
# C++ Compile and Run
FILENAME="$GEDIT_CURRENT_DOCUMENT_DIR/$GEDIT_CURRENT_DOCUMENT_NAME"
PROGNAME="$GEDIT_CURRENT_DOCUMENT_DIR/${GEDIT_CURRENT_DOCUMENT_NAME%.*}"

g++ "$FILENAME" -o "$PROGNAME" -Wall -Wextra -fsanitize=address

if [ $? -eq 0 ]; then
echo "Compile Succeed!"
else
echo "Compile Failed!"
exit
fi

echo "Running..."
gnome-terminal -- bash -c "time -p \"$PROGNAME\"; echo \"-----------------------------------------------
The program has exited with returning value \$?\"; echo \"Press <Any Key> to exit...\"; read -n 1" > /dev/null
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh
# C++ Compile and Debug
FILENAME="$GEDIT_CURRENT_DOCUMENT_DIR/$GEDIT_CURRENT_DOCUMENT_NAME"
PROGNAME="$GEDIT_CURRENT_DOCUMENT_DIR/${GEDIT_CURRNET_DOCUMENT_NAME%.*}"

g++ "$FILENAME" -o "$PROGNAME" -Wall -Wextra -fsanitize=address -g3

if [ $? -eq 0 ]; then
echo "Compile Succeed!"
else
echo "Compile Failed!"
exit
fi

echo "Launching Debugger..."
gnome-terminal -- bash -c "gdb $PROGNAME"

Windows:考场自动化对拍程序(.bat

文件输入输出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
@echo off
g++ (输入数据生成器).cpp -o (输入数据生成器).exe
g++ (对拍用程序).cpp -o (对拍用程序).exe
g++ (待对拍程序).cpp -o (待对拍程序).exe
for /L %%i in (1, 1, 100) do (
echo 第%%i组数据
(输入数据生成器).exe
(对拍用程序).exe
(待对拍程序).exe
fc /W (输出文件名).out (输出文件名).ans > nul
if ERRORLEVEL 1 (
echo Wrong Answer...
) else (
echo Accepted Output...
)
pause
)

标准输入输出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
@echo off
g++ (输入数据生成器).cpp -o (输入数据生成器).exe
g++ (对拍用程序).cpp -o (对拍用程序).exe
g++ (待对拍程序).cpp -o (待对拍程序).exe
for /L %%i in (1, 1, 100) do (
echo 第%%i组数据
(输入数据生成器).exe >temp.in
(对拍用程序).exe <temp.in >temp.ans
(待对拍程序).exe <temp.in >temp.out
fc /W temp.out temp.ans > nul
if ERRORLEVEL 1 (
echo Wrong Answer...
) else (
echo Accepted Output...
)
pause
)

 评论