consolidate all repos to one for archive
This commit is contained in:
3
semester_2/podatkovne_strukture/naloga_1/.gitignore
vendored
Normal file
3
semester_2/podatkovne_strukture/naloga_1/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
.idea/*
|
||||
cmake-build-debug/*
|
||||
CMakeLists.txt
|
1
semester_2/podatkovne_strukture/naloga_1/README.md
Normal file
1
semester_2/podatkovne_strukture/naloga_1/README.md
Normal file
@@ -0,0 +1 @@
|
||||
Navodila v folder navodila
|
131
semester_2/podatkovne_strukture/naloga_1/main.cpp
Normal file
131
semester_2/podatkovne_strukture/naloga_1/main.cpp
Normal file
@@ -0,0 +1,131 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct Student {
|
||||
string Ime;
|
||||
string Priimek;
|
||||
string IDUM; };
|
||||
|
||||
// prototipi
|
||||
void izpisi_seznam(list<Student>);
|
||||
void izpisi_studenta(Student);
|
||||
void vstavi(list<Student> &, int, Student);
|
||||
Student vrni(list<Student>, int);
|
||||
void vrini(list<Student> &, int, Student);
|
||||
Student odstrani(list<Student> &, int);
|
||||
|
||||
void izpisi_seznam(list<Student> seznam)
|
||||
{
|
||||
for (list<Student>::iterator it = seznam.begin(); it != seznam.end(); ++it)
|
||||
{
|
||||
Student st = *it;
|
||||
izpisi_studenta(st);
|
||||
}
|
||||
}
|
||||
|
||||
void izpisi_studenta(Student st)
|
||||
{
|
||||
cout << "Ime: " << st.Ime << endl << "Priimek: " << st.Priimek << endl << "IDUM: " << st.IDUM << endl << endl;
|
||||
}
|
||||
|
||||
void vstavi(list<Student> &seznam, int indeks, Student podatek)
|
||||
{
|
||||
if (indeks < 0 || indeks >= seznam.size() || seznam.empty()) {
|
||||
return;
|
||||
}
|
||||
auto index = seznam.begin();
|
||||
advance(index, indeks);
|
||||
*index = podatek;
|
||||
}
|
||||
|
||||
Student vrni(const list<Student> seznam, int indeks)
|
||||
{
|
||||
Student student;
|
||||
if (indeks < 0 || indeks >= seznam.size() || seznam.empty()) return student;
|
||||
auto index = seznam.begin();
|
||||
advance(index, indeks);
|
||||
student = *index;
|
||||
return student;
|
||||
return Student();
|
||||
}
|
||||
|
||||
void vrini(list<Student> &seznam, int indeks, Student podatek)
|
||||
{
|
||||
if (indeks < 0) {
|
||||
return;
|
||||
}
|
||||
else if(indeks >= seznam.size() || seznam.empty()){
|
||||
seznam.push_back(podatek);
|
||||
return;
|
||||
}
|
||||
auto index = seznam.begin();
|
||||
advance(index, indeks);
|
||||
seznam.insert(index, podatek);
|
||||
}
|
||||
|
||||
Student odstrani(list<Student> &seznam, int indeks)
|
||||
{
|
||||
Student student;
|
||||
if (indeks < 0 || indeks >= seznam.size() || seznam.empty()) return student;
|
||||
auto index = seznam.begin();
|
||||
advance(index, indeks);
|
||||
student = *index;
|
||||
seznam.erase(index);
|
||||
return student;
|
||||
return Student();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int tmp;
|
||||
|
||||
list<Student> students;
|
||||
|
||||
Student st1 = {"jan", "bel", "243"};
|
||||
Student st2 = {"pet" , "jsad", "324"};
|
||||
Student st3 = {"asndlk", "ndsia", "345"};
|
||||
Student st4 = {"nilp", "dsag", "365"};
|
||||
Student st5 = {"dsag", "sadgn", "268"};
|
||||
Student tmpStud;
|
||||
|
||||
|
||||
students.push_back(st1);
|
||||
students.push_back(st2);
|
||||
students.push_back(st3);
|
||||
|
||||
izpisi_seznam(students);
|
||||
|
||||
|
||||
cout<<"Naloga 1:"<<endl;
|
||||
cin >> tmp;
|
||||
|
||||
vstavi(students, tmp, st4);
|
||||
izpisi_seznam(students);
|
||||
|
||||
cout<<"Naloga 2:"<<endl<<endl;
|
||||
cin >> tmp;
|
||||
|
||||
tmpStud=vrni(students, tmp);
|
||||
izpisi_studenta(tmpStud);
|
||||
|
||||
cout<<"Naloga 3:"<<endl<<endl;
|
||||
cin >> tmp;
|
||||
|
||||
vrini(students, tmp, st5);
|
||||
izpisi_seznam(students);
|
||||
|
||||
cout<<"Naloga 4:"<<endl<<endl;
|
||||
cin >> tmp;
|
||||
|
||||
tmpStud=odstrani(students, tmp);
|
||||
izpisi_studenta(tmpStud);
|
||||
|
||||
|
||||
izpisi_seznam(students);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user