Untitled

 avatar
unknown
c_cpp
4 years ago
700 B
6
Indexable
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

struct element{
    int val;
    element *next = nullptr;
};

struct kolejka{
    element *head = nullptr;
    element *tail = nullptr;
};

void push(kolejka &obj, int value){
    element *el = new element;
    el->val = value;
    if( obj.tail != nullptr){
        obj.tail->next = el;
    }
    else{
        obj.head = el;
    }
    obj.tail = el;
}

int main(){
    kolejka obj1;
    ifstream file("zadanie1_a.txt");
    string liczba;
    while(file.good()){
        getline(file,liczba,'\n');
        push(obj1, stoi(liczba));
    }
    file.close();
    
    
    return 0;
}
Editor is loading...