Untitled
unknown
c_cpp
5 years ago
700 B
10
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...