插入代码不会自动换行,我也是佛了

#include<bits/stdc++.h>
using namespace std;
mutex mtx;
int active = 0;
int n;
void print(int thread_idx, int k , char c){
    int i = 0;
    cout << thread_idx << endl;
    while(i < k) {
        mtx.lock();
        if(active == thread_idx){
            cout << c ;
            active = (active++)%n;
            i++;
        }
        mtx.unlock();
    }
}
int main(){
    cin >> n;
    string s;
    cin >> s;
    vector<thread> vth;
    for(int i = 0; i < s.size(); i++){
        vth.push_back(move(thread(print, i, n, s[i])));
    }
    for(auto &t : vth)
        t.join();
    return 0;
}