Advertisement
Guest User

fasfdasfas

a guest
Feb 26th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. struct student // etap 1.1
  7. {
  8.     string imie;
  9.     string nazwisko;
  10.     string plec;
  11.     string nr_indeks;
  12.     string nr_pesel;
  13. };
  14.  
  15.  
  16.  
  17. void display_student( student & s1 )
  18. {
  19.             //etap 1.2 i 1.3
  20.     cout << "podaj imie studenta" << endl;
  21.     cin >> s1.imie;
  22.     cout << "podaj nazwisko" << endl;
  23.     cin >> s1.nazwisko;
  24.     cout << "podaj plec studenta "<< endl;
  25.     cin >> s1.plec;
  26.     cout << "podaj nr indeksu studenta" << endl;
  27.     cin >> s1.nr_indeks;
  28.     cout << "podaj nr pesel studenta" << endl;
  29.     cin >> s1.nr_pesel;
  30.     cout << endl;
  31. }
  32. void display_all_students(student tab[], int tab_size)
  33. {
  34.  
  35.     for(int i = 0; i < tab_size; i++)
  36.     {
  37.         display_student(tab[i]);
  38.     }
  39. }    //etap 1.5
  40.  
  41. int main()
  42. {
  43.     int liczba_studentow = 3;
  44.  
  45.     student s1; // typ i nazwa zmiennej s1
  46.     display_student(s1);//wywolanie funkcji
  47.     //etap.4
  48.     // student jest typem jak np: int ...
  49.     student tab[liczba_studentow]; // tablica 3 studentow
  50.  
  51.     //dane pierwszego studenta
  52.     tab[0].imie = "Jan";
  53.     tab[0].nazwisko = "Janowski";
  54.     tab[0].plec = "mezczyzna";
  55.     tab[0].nr_indeks = "321321";
  56.     tab[0].nr_pesel = "4324235432";
  57.     //dane drugiego studenta
  58.     tab[1].imie = "Mikolaj";
  59.     tab[1].nazwisko = "Swiety";
  60.     tab[1].plec = "mezczyzna";
  61.     tab[1].nr_indeks = "432421";
  62.     tab[1].nr_pesel = "234235432";
  63.     //dane trzeciego studenta
  64.     tab[2].imie = "Piotr";
  65.     tab[2].nazwisko = "Pan";
  66.     tab[2].plec = "mezczyzna";
  67.     tab[2].nr_indeks = "543521";
  68.     tab[2].nr_pesel = "5345635432";
  69.  
  70.     //wywolanie funkcji
  71.     display_all_students(tab ,liczba_studentow);
  72.  
  73.     return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement