passwordsol

 avatar
quoc14
c_cpp
a month ago
1.0 kB
1
Indexable
Never
caidat
// Online C++ compiler to run C++ program online
#include <iostream>

using namespace std;
int queue[10111];
int cur = 0;

void insert(int x) {
    cur++;
    queue[cur] = x;
}

void pop() {
    
    cur--;
    for (int i = 1; i <= cur; i++) {
        queue[i] = queue[i+1];
    }
}

bool isEmpty() {
    if (cur == 0) {
        return true;
    }
    return false;
}

int a[10011];
void show() {
    
    for (int i = 1; i <= cur; i++) {
        
        cout << queue[i] << " ";
    }
    cout << endl;
}
int main() {
    // Write C++ code here
    
    for (int i = 1; i <= 8; i++) {
        cin >> a[i];
        insert(a[i]);
        
    }    
    int tmp = 1;
    
    while (true) {
        if (tmp == 6) {
            tmp = 1;
        }
        if (queue[8] == 0) {
            break;
        }
        int top = queue[1];
        
        pop();
        int a = top - tmp;
        if (a < 0) {
            a = 0;
        }
        insert(a);
        tmp++;
        
    }
    
    show();
    
}
Leave a Comment