How to implement a gantt chart

Hello i want to integrate a combined CPU scheduling gantt chart,
Here is my code without a gantt chart (this works perfectly, but still no gantt chart):

#include <iostream>
#include <fstream>
#include <vector>
#include <limits>
#include <iomanip>

using namespace std;

class Process {
public:
    int process_n;
    int a_time;
    int b_time;
    int prio;

    int rem_time;

    int res_time;
    int com_time;

    int w_time;
    int t_time;

    void initialize() {
        rem_time = b_time;
    }
};

int main() {
    ifstream infile("input.txt");  // Open input file
    if (!infile) {
        cerr << "Error opening input file." << 'n';
        return 1;
    }

    int proc;
    infile >> proc;  // Read number of processes from file

    vector<Process> processes(proc);

    //processes
    cout << "Number of process: " << proc << 'n';
    cout << 'n';
    
    //arrival time
    cout << "Arrival time:n";
    for (int i = 0; i < proc; ++i) {
        infile >> processes[i].a_time;
        cout << "P" << i + 1 << ": " << processes[i].a_time << 'n';
    }
    cout << 'n';

    //burst time
    cout << "Burst time:n";
    for (int i = 0; i < proc; ++i) {
        infile >> processes[i].b_time;
        cout << "P" << i + 1 << ": " << processes[i].b_time << 'n';
    }
    cout << 'n';

    //priority
    cout << "Priority:n";
    for (int i = 0; i < proc; ++i) {
        infile >> processes[i].prio;
        cout << "p" << i + 1 << ": " << processes[i].prio << 'n';
        processes[i].initialize();
    }
    
    //pid
    for (int i = 0; i < proc; i++){
        processes[i].process_n = i + 1;
    }
    cout << 'n';

    infile.close();  // Close the input file


    int curr_time = 0;

    while (true) {
        int curr_high_priority_index = -1;
        int curr_high_priority = numeric_limits<int>::max();

        bool all_completed = true;

        for (int i = 0; i < proc; ++i) {
            if (processes[i].rem_time > 0) {
                all_completed = false;
                if (processes[i].a_time <= curr_time) {
                    if (processes[i].prio < curr_high_priority) {
                        curr_high_priority = processes[i].prio;
                        curr_high_priority_index = i;
                    }
                }
            }
        }

        if (all_completed) {
            break;
        }

        if (processes[curr_high_priority_index].rem_time == processes[curr_high_priority_index].b_time) {
            processes[curr_high_priority_index].res_time = curr_time;
        }

        processes[curr_high_priority_index].rem_time--;
        curr_time++;

        if (processes[curr_high_priority_index].rem_time == 0) {
            processes[curr_high_priority_index].com_time = curr_time;
        }
    }

    // Output results
    int sum_res_time = 0;
    int sum_com_time = 0;
    int sum_w_time = 0;
    int sum_t_time = 0;
    
    //table
    cout << "Process Table:n";
    cout << "+-----------+-----------------+--------------+" << 'n';
    cout << "|  Process  | Turnaround Time | Waiting Time |" << 'n';
    cout << "+-----------+-----------------+--------------+" << 'n';

    for (int n = 0; n < proc; ++n) {
        processes[n].t_time = processes[n].com_time - processes[n].a_time;
        processes[n].w_time = processes[n].t_time - processes[n].b_time;

        cout << "| P" << processes[n].process_n << setw(9) << "|";
        cout << setw(10) << processes[n].t_time << setw(8) << "|";
        cout << setw(8) << processes[n].w_time << setw(7) << "|" << 'n';
        
        sum_res_time += processes[n].res_time;
        sum_com_time += processes[n].com_time;
        sum_w_time += processes[n].w_time;
        sum_t_time += processes[n].t_time;
    }
    int ave_t_time = (sum_t_time / proc);
    int ave_w_time = (sum_w_time / proc);
    
    //total and aevrage
    cout << "+-----------+-----------------+--------------+" << 'n';
    cout << "|   Total   |" << setw(10) << sum_t_time << setw(8) << "|" << setw(8) << sum_w_time << setw(7) << "|" << 'n';
    cout << "+-----------+-----------------+--------------+" << 'n';
    cout << "|  Average  |" << setw(10) << ave_t_time << setw(8) << "|" << setw(8) << ave_w_time << setw(7) << "|" << 'n';
    cout << "+-----------+-----------------+--------------+" << 'n';
    
    return 0;
}

i got lots of incorrect outputs
this is the example

<= 2(priority) background process (FCFS)

= 1(priority) foreground process (RR Q=2)

example input:

number of process = 4

arrival time
p1: 0
p2: 2
p3: 4
p4: 5

burst time
p1: 7
p2: 4
p3: 1
p4: 4

priority
p1: 2
p2: 1
p3: 2
p4: 1

example gantt chart:

<-FCFS-> <———-RR Q=2————-> <—–FCFS—–>
|p1 |p2 |p2 |p4 |p4 |p1 |p3 |
0 2 4 6 8 10 15 16

New contributor

chae is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật