Advertisement
Guest User

Untitled

a guest
Jan 17th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. struct student {
  7. string imie;
  8. string nazwisko;
  9. string plec;
  10. string pesel;
  11. string nr_indeksu;
  12. };
  13.  
  14. void display_student(student osoba) {
  15. cout << "Imie: " << osoba.imie << endl;
  16. cout << "Nazwisko: " << osoba.nazwisko << endl;
  17. cout << "plec: " << osoba.plec << endl;
  18. cout << "pesel: " << osoba.pesel << endl;
  19. cout << "nr_indeksu: " << osoba.nr_indeksu << endl;
  20. cout << "\n";
  21. }
  22.  
  23. void zad4(student tablica[]) {
  24. tablica[0].imie = "Piotr";
  25. tablica[0].nazwisko = "Kowalski";
  26. tablica[0].plec = "M";
  27. tablica[0].pesel = "98010110176";
  28. tablica[0].nr_indeksu = "241000";
  29.  
  30. tablica[1].imie = "Jan";
  31. tablica[1].nazwisko = "Nowak";
  32. tablica[1].plec = "M";
  33. tablica[1].pesel = "97080110176";
  34. tablica[1].nr_indeksu = "241050";
  35.  
  36. tablica[2].imie = "Ola";
  37. tablica[2].nazwisko = "Wojcik";
  38. tablica[2].plec = "K";
  39. tablica[2].pesel = "98010110876";
  40. tablica[2].nr_indeksu = "241700";
  41. }
  42.  
  43. void display_all_students(student tablica[], int liczba) {
  44. for (int i = 0; i < liczba; i++) {
  45. display_student(tablica[i]);
  46. };
  47. }
  48.  
  49. int find_student(student tablica[], int liczba, string indeks) {
  50. int pozycja = -1;
  51. for (int i = 0; i < liczba; i++) {
  52. //cout<<tablica[i].nr_indeksu<<endl;
  53. if (tablica[i].nr_indeksu == indeks) {
  54. pozycja = i;
  55. };
  56. };
  57. return pozycja;
  58. }
  59.  
  60. void add_student(string imie, string nazwisko, string plec, string pesel, string indeks, int pozycja, student tablica[]) {
  61. tablica[pozycja].imie = imie;
  62. tablica[pozycja].nazwisko = nazwisko;
  63. tablica[pozycja].plec = plec;
  64. tablica[pozycja].pesel = pesel;
  65. tablica[pozycja].nr_indeksu = indeks;
  66. }
  67.  
  68. void remove_student(student tablica[], int pozycja) {
  69. tablica[pozycja].imie = "";
  70. tablica[pozycja].nazwisko = "";
  71. tablica[pozycja].plec = "";
  72. tablica[pozycja].pesel = "";
  73. tablica[pozycja].nr_indeksu = "";
  74. }
  75.  
  76. int main()
  77. {
  78.  
  79. //ZADANIE1
  80. /* student1;
  81. cout<<"Podaj Imie: "<<endl;
  82. cin>>student1.imie;
  83. cout<<"Podaj Nazwisko: "<<endl;
  84. cin>>student1.nazwisko;
  85. cout<<"Podaj Plec: "<<endl;
  86. cin>>student1.plec;
  87. cout<<"Podaj pesel: "<<endl;
  88. cin>>student1.pesel;
  89. cout<<"Podaj nr_indeksu: "<<endl;
  90. cin>>student1.nr_indeksu;*/
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97. //zadanie3
  98. //display_student(student1);
  99. //
  100.  
  101. student tablica_studenci[20];
  102.  
  103. //wypelnienie danymi
  104. zad4(tablica_studenci);
  105. //
  106.  
  107. //zadanie 5
  108. //display_all_students(tablica_studenci,3);
  109.  
  110. //zadanie 6
  111. //cout<<find_student(tablica_studenci,3,"241700");
  112. //
  113.  
  114. //zadanie 7
  115. //add_student("Tomasz", "Drabik", "M", "970000000", "258000", 3, tablica_studenci);
  116. //display_all_students(tablica_studenci,4);
  117. //
  118.  
  119. //zadanie 8
  120. //remove_student(tablica_studenci,3);
  121. //display_all_students(tablica_studenci,3);
  122. //
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement