A lightweight C++ judging system that supports account login, problem management, code compilation, and test case comparison.
This project is an extended and refactored version of a classroom assignment, enhanced with a more complete interaction flow, structured file management, and cross-platform support.
Original Author (Teaching Assistant): Colten Chen
Assignment Links:
.
├── data/
│ ├── problem/
│ │ ├── <problem-name>/
│ │ │ ├── testcases/ # Test files (.in/.out)
│ │ │ ├── description.txt # Problem description
│ │ └── problems.csv # Problem metadata
│ ├── user/
│ │ ├── program/ # # User-submitted code
│ │ ├── user_output.txt # Program output from user submission
│ │ ├── users.csv # User account data
│
├── include/ # All .hpp header files
│ ├── Account.hpp
│ ├── Problem.hpp
│ ├── Judge.hpp
│ ├── ColorPrint.hpp
│ └── Utils.hpp
│
├── src/ # All .cpp source files
│ ├── Account.cpp
│ ├── Problem.cpp
│ ├── Judge.cpp
│ └── Utils.cpp
│
├── build/ # Compiled executables
│ ├── judge_system.exe
│ └── user_program.exe
│
├── README.md
└── main.cpp
Use g++ to compile:
# Create build directory
mkdir -p build
# Compile (single command)
g++ main.cpp src/*.cpp -I include -o build/judge_system -std=c++17
# Run
./build/judge_system- Initialize account and problem system
- Support user login and management
- Admin account can add new problems
- View current user
- Show system version
- Display problem list and select a problem
- Random problem selection
- Submit code directly
- Add new problem (admin only)
- Logout
- Exit system
- Compile user-submitted C++ code
- Automatically test against problem test cases
- Compare output with expected results line by line
- Display result (Accepted / Wrong Answer / Runtime Error / Compile Error)
- Login Flow
- Main Menu Flow
- Code Submission Flow
-
Modular File Structure
- Headers (
.hpp) and sources (.cpp) fully separated intoinclude/andsrc/ - Added
build/for compiled outputs - Each problem managed in
<problem-name>/with description and test cases
- Headers (
-
Cross-Platform Support
- Conditional compilation with
#ifdef _WIN32for Windows/Linux distinction - Auto-generate corresponding compile and run commands
- Conditional compilation with
-
Interactive Terminal Interface
- Added
ColorPrintfor colored and highlighted output - Loading animation and screen-clearing for smoother UX
- Added
-
Enhanced Problem Management
- Auto-generate problem folders,
description.txt, andtestcases problems.csvupdated instantly when a new problem is added
- Auto-generate problem folders,
-
Improved Judging Workflow
- Auto-compile, execute, and test against multiple cases after submission
- Display detailed results with error types
-
Refactored Codebase
- Reusable functions moved into
Utilsnamespace - Reduced redundant loops for better efficiency and readability
- Reusable functions moved into
-
Input Validation & Error Handling
- Verify input format and range
- Retry loops to prevent crashes from invalid input


