Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Zaprojektuj strukture ktora bedzie przechowywala dane : char nazwisko[64]; long ID_pracownika; float zarobki; char telefon[10]; int numer biura;
- Utworz zmienna(obiekt) typu tej struktury(nazwa np stażysta, student)
- 1. wpisz dane do tej zmiennej(z programu)
- a) korzystajac z operatora dostepu bezposredniego(.)
- b) korzystajac z operatora dostepu posredniego(->).Użyj wskaźnika na zmienna strukturalną.
- Wypisz dane z tej zmiennej(struktury) aby sprawdzić prawidłowość inicjalizacji zmiennych składowych.
- 2. Wpisz dane do tej zmiennej z klawiatury(operator wpisuje dane)
- 3. Stworz funkcje wpisz() ktora bedzie wpisywala dane na polu zmiennej
- typ struktury i funkcji wpisz ktora sprawdzi co jest wpisane
- */
- #include <iostream>
- #include <string>
- using namespace std;
- void bezposredni(struct pracownicy& student);
- void wpisz(struct pracownicy& student);
- void wypisz(struct pracownicy& student);
- void posredni(struct pracownicy* student);
- struct pracownicy
- {
- string nazwisko;
- long ID_pracownika;
- float zarobki;
- int telefon;
- int numer_biura;
- };
- int main()
- {
- pracownicy student;
- bezposredni(student);
- wypisz(student);
- wpisz(student);
- posredni(&student);
- wypisz(student);
- }
- void posredni(pracownicy* student)
- {
- student->nazwisko = "Kowalski";
- student->ID_pracownika = 152;
- student->zarobki = 0;
- student->telefon = 123456789;
- student->numer_biura = 20;
- }
- void wpisz(pracownicy& student)
- {
- cout << "Wprowadz nazwisko : ";
- cin >> student.nazwisko;
- cout << "Wprowadz Id pracownika : ";
- cin >> student.ID_pracownika;
- cout << "Wprowadz zarobki : ";
- cin >> student.zarobki;
- cout << "Wprowadz telefon : ";
- cin >> student.telefon;
- cout << "Wprowadz numer biura : ";
- cin >> student.numer_biura;
- }
- void bezposredni(pracownicy& student)
- {
- student.nazwisko = "Kowalski";
- student.ID_pracownika = 152;
- student.zarobki = 0;
- student.telefon = 123456789;
- student.numer_biura = 20;
- }
- void wypisz(pracownicy& student)
- {
- cout << "Nazwisko : " << student.nazwisko << endl;
- cout << "Id pracownika : " << student.ID_pracownika << endl;
- cout << "Zarobki : " << student.zarobki << endl;
- cout << "Telefon : " << student.telefon << endl;
- cout << "Numer biura : " << student.numer_biura << endl << endl;;
- system("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement