Advertisement
Guest User

structury

a guest
Mar 26th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.25 KB | None | 0 0
  1. /* Zaprojektuj strukture ktora bedzie przechowywala dane : char nazwisko[64]; long ID_pracownika; float zarobki; char telefon[10]; int numer biura;
  2. Utworz zmienna(obiekt) typu tej struktury(nazwa np stażysta, student)
  3. 1. wpisz dane do tej zmiennej(z programu)
  4. a) korzystajac z operatora  dostepu bezposredniego(.)
  5. b) korzystajac z operatora dostepu posredniego(->).Użyj wskaźnika na zmienna strukturalną.
  6. Wypisz dane z tej zmiennej(struktury) aby sprawdzić prawidłowość inicjalizacji zmiennych składowych.
  7. 2. Wpisz dane do tej zmiennej z klawiatury(operator wpisuje dane)
  8. 3. Stworz funkcje wpisz() ktora bedzie wpisywala dane na polu zmiennej
  9. typ struktury i funkcji wpisz ktora sprawdzi co jest wpisane
  10. */
  11. #include <iostream>
  12. #include <string>
  13. using namespace std;
  14. void bezposredni(struct pracownicy& student);
  15. void wpisz(struct pracownicy& student);
  16. void wypisz(struct pracownicy& student);
  17. void posredni(struct pracownicy* student);
  18. struct pracownicy
  19. {
  20.     string nazwisko;
  21.     long ID_pracownika;
  22.     float zarobki;
  23.     int telefon;
  24.     int numer_biura;
  25. };
  26. int main()
  27. {
  28.     pracownicy student;
  29.  
  30.     bezposredni(student);
  31.     wypisz(student);
  32.     wpisz(student);
  33.     posredni(&student);
  34.     wypisz(student);
  35. }
  36. void posredni(pracownicy* student)
  37. {
  38.     student->nazwisko = "Kowalski";
  39.     student->ID_pracownika = 152;
  40.     student->zarobki = 0;
  41.     student->telefon = 123456789;
  42.     student->numer_biura = 20;
  43. }
  44. void wpisz(pracownicy& student)
  45. {
  46.     cout << "Wprowadz nazwisko : ";
  47.     cin >> student.nazwisko;
  48.     cout << "Wprowadz Id pracownika : ";
  49.     cin >> student.ID_pracownika;
  50.     cout << "Wprowadz zarobki : ";
  51.     cin >> student.zarobki;
  52.     cout << "Wprowadz telefon : ";
  53.     cin >> student.telefon;
  54.     cout << "Wprowadz numer biura : ";
  55.     cin >> student.numer_biura;
  56. }
  57. void bezposredni(pracownicy& student)
  58. {
  59.     student.nazwisko = "Kowalski";
  60.     student.ID_pracownika = 152;
  61.     student.zarobki = 0;
  62.     student.telefon = 123456789;
  63.     student.numer_biura = 20;
  64. }
  65. void wypisz(pracownicy& student)
  66. {
  67.     cout << "Nazwisko : " << student.nazwisko << endl;
  68.     cout << "Id pracownika : " << student.ID_pracownika << endl;
  69.     cout << "Zarobki : " << student.zarobki << endl;
  70.     cout << "Telefon : " << student.telefon << endl;
  71.     cout << "Numer biura : " << student.numer_biura << endl << endl;;
  72.     system("PAUSE");
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement