Menu
Coddy logo textTech

הכנסה לתור

שיעור 4 מתוך 12 בקורס תור – סדרת מבני הנתונים #2 של Coddy.

challenge icon

אתגר

קל

הוסף ל־Queue מתודה בשם enqueue שמקבלת מספר שלם ומוסיפה אותו לתור.

נסו בעצמכם

#include <iostream>
#include <sstream>
#include <string>
#include "queue.h"

int main() {
    Queue q;
    std::string line;
    while (std::getline(std::cin, line)) {
        std::istringstream iss(line);
        std::string cmd;
        if (!(iss >> cmd)) continue;
        if (cmd == "enqueue") {
            int x; iss >> x; q.enqueue(x);
        }
    }
    for (int item : q.items) {
        std::cout << item << std::endl;
    }
    return 0;
}

כל השיעורים ביחידה תור – סדרת מבני הנתונים #2

תרגלו בעצמכם: קומפיילר C אונליין