#include <iostream>

int main() {
    std::cout << "Hello world!" << std::endl;
    return 0;
}#include <iostream>
#include <windows.h>
#include <vector>
#include <string>

// 파이썬 파일을 독립된 창(프로세스)으로 실행하는 함수입니다.
void runPythonScript(const std::string& scriptName) {
    // python scriptName.py 명령어를 실행하도록 설정합니다.
    std::string command = "cmd.exe /c python " + scriptName;
    
    STARTUPINFOA si;
    PROCESS_INFORMATION pi;

    ZeroMemory(&si, sizeof(si));
    si.cb = sizeof(si);
    ZeroMemory(&pi, sizeof(pi));

    // 새로운 명령 프롬프트 창을 띄워 파이썬을 실행합니다.
    if (!CreateProcessA(
        NULL, 
        const_cast<char*>(command.c_str()), 
        NULL, NULL, FALSE, 
        CREATE_NEW_CONSOLE, // 새 창에서 실행
        NULL, NULL, &si, &pi)) 
    {
        std::cerr << scriptName << " 실행 실패! 에러 코드: " << GetLastError() << std::endl;
        return;
    }

    // 핸들을 닫아줍니다 (프로그램은 백그라운드나 새 창에서 계속 돕니다).
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
}

int main() {
    // 동시에 실행할 파이썬 파일 이름들입니다.
    std::vector<std::string> scripts = { "code1.py", "code2.py", "code3.py", "code4.py" };

    std::cout << "4개의 파이썬 파일을 동시에 실행합니다...\n";

    // 4개의 프로그램을 쉼 없이 연속으로 실행시켜서 "동시"에 뜨게 만듭니다.
    for (const auto& script : scripts) {
        runPythonScript(script);
    }

    std::cout << "모든 프로그램이 작동 중입니다. 이 창을 닫으면 종료될 수 있습니다.\n";
    system("pause"); // 프로그램이 바로 꺼지지 않게 대기합니다.
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: