250x250
Notice
Recent Posts
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
관리 메뉴

일상 코딩

[C++ / inflearn] M1 VSCode C++ 김태원 코딩테스트 자동채점 mac os 구현 본문

C++/inflearn C++ 강의 세팅

[C++ / inflearn] M1 VSCode C++ 김태원 코딩테스트 자동채점 mac os 구현

polarcompass 2021. 10. 10. 05:06
728x90

1.출처

https://www.inflearn.com/questions/322413

 

맥북(mac os) 자동 채점 방법을 고민해보았습니다. - 인프런 | 질문 & 답변

출력값이 긴 파일은 하나씩 눈으로 보고 체크하기가 어려워서 방법을 찾아보았습니다. 별다른 설치 파일 필요 없이 그냥 리눅스 명령어로 만들어진 쉘 스크립트만 생성해주면 되므로 간단합니

www.inflearn.com

2. 쉘 스크립트 생성

#!/bin/bash
g++ code.cpp -o code
"./code" "./test/in1.txt" "./test/result1.txt"
"./code" "./test/in2.txt" "./test/result2.txt"
"./code" "./test/in3.txt" "./test/result3.txt"
"./code" "./test/in4.txt" "./test/result4.txt"
"./code" "./test/in5.txt" "./test/result5.txt"

echo "test1 :" && diff -w -s "./test/result1.txt" "./test/out1.txt"&& echo  " "
echo "test2 :" &&diff -w -s "./test/result2.txt" "./test/out2.txt"&& echo  " "
echo "test3 :" &&diff -w -s "./test/result3.txt" "./test/out3.txt"&& echo  " "
echo "test4 :" &&diff -w -s "./test/result4.txt" "./test/out4.txt"&& echo  " "
echo "test5 :" &&diff -w -s "./test/result5.txt" "./test/out5.txt"&& echo  " "

위 코드를 run.sh 파일에 붙여 넣어준다.

실행 파일은 code.cpp로 만들어 준다.

3. 파일 설정

input.txt 와 output.txt를

test 폴더로 옮겨준다.

90 몇개의 폴더를 전부 위 형식으로 세팅해준다.

한번에 하기보단 강의를 들을때마다 해주면 될 것이다.

4. main() 코드 수정

int main(int argc, char* argv[]){
	freopen(argv[1], "rt", stdin);
	freopen(argv[2], "w", stdout);

5. 실행

$ cd num39

터미널에서 num39 폴더로 이동 후 

$ sh run.sh

위 코드를 실행한다.

6. 결과 확인

성공시 identical 이라고 뜨게 된다.

추가 정보는 출처 링크로 들어가시면 될것 같습니다.

728x90