Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- struct student {
- string imie;
- string nazwisko;
- string plec;
- string pesel;
- string nr_indeksu;
- };
- void display_student(student osoba) {
- cout << "Imie: " << osoba.imie << endl;
- cout << "Nazwisko: " << osoba.nazwisko << endl;
- cout << "plec: " << osoba.plec << endl;
- cout << "pesel: " << osoba.pesel << endl;
- cout << "nr_indeksu: " << osoba.nr_indeksu << endl;
- cout << "\n";
- }
- void zad4(student tablica[]) {
- tablica[0].imie = "Piotr";
- tablica[0].nazwisko = "Kowalski";
- tablica[0].plec = "M";
- tablica[0].pesel = "98010110176";
- tablica[0].nr_indeksu = "241000";
- tablica[1].imie = "Jan";
- tablica[1].nazwisko = "Nowak";
- tablica[1].plec = "M";
- tablica[1].pesel = "97080110176";
- tablica[1].nr_indeksu = "241050";
- tablica[2].imie = "Ola";
- tablica[2].nazwisko = "Wojcik";
- tablica[2].plec = "K";
- tablica[2].pesel = "98010110876";
- tablica[2].nr_indeksu = "241700";
- }
- void display_all_students(student tablica[], int liczba) {
- for (int i = 0; i < liczba; i++) {
- display_student(tablica[i]);
- };
- }
- int find_student(student tablica[], int liczba, string indeks) {
- int pozycja = -1;
- for (int i = 0; i < liczba; i++) {
- //cout<<tablica[i].nr_indeksu<<endl;
- if (tablica[i].nr_indeksu == indeks) {
- pozycja = i;
- };
- };
- return pozycja;
- }
- void add_student(string imie, string nazwisko, string plec, string pesel, string indeks, int pozycja, student tablica[]) {
- tablica[pozycja].imie = imie;
- tablica[pozycja].nazwisko = nazwisko;
- tablica[pozycja].plec = plec;
- tablica[pozycja].pesel = pesel;
- tablica[pozycja].nr_indeksu = indeks;
- }
- void remove_student(student tablica[], int pozycja) {
- tablica[pozycja].imie = "";
- tablica[pozycja].nazwisko = "";
- tablica[pozycja].plec = "";
- tablica[pozycja].pesel = "";
- tablica[pozycja].nr_indeksu = "";
- }
- int main()
- {
- //ZADANIE1
- /* student1;
- cout<<"Podaj Imie: "<<endl;
- cin>>student1.imie;
- cout<<"Podaj Nazwisko: "<<endl;
- cin>>student1.nazwisko;
- cout<<"Podaj Plec: "<<endl;
- cin>>student1.plec;
- cout<<"Podaj pesel: "<<endl;
- cin>>student1.pesel;
- cout<<"Podaj nr_indeksu: "<<endl;
- cin>>student1.nr_indeksu;*/
- //zadanie3
- //display_student(student1);
- //
- student tablica_studenci[20];
- //wypelnienie danymi
- zad4(tablica_studenci);
- //
- //zadanie 5
- //display_all_students(tablica_studenci,3);
- //zadanie 6
- //cout<<find_student(tablica_studenci,3,"241700");
- //
- //zadanie 7
- //add_student("Tomasz", "Drabik", "M", "970000000", "258000", 3, tablica_studenci);
- //display_all_students(tablica_studenci,4);
- //
- //zadanie 8
- //remove_student(tablica_studenci,3);
- //display_all_students(tablica_studenci,3);
- //
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement