Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "stdio.h"
- using namespace std;
- struct pracownik
- {
- char nazwisko[25];
- float wyplata;
- int wiek;
- };
- bool suma(pracownik t[], int ile, float *s, float *sr)
- {
- if(ile <= 0)
- return 0;
- *s = 0;
- for(int i = 0; i < ile; i++)
- *s += t[i].wyplata;
- *sr = *s/ile;
- return 1;
- }
- int main()
- {
- int stan = 3;
- pracownik kadra[stan];
- float su, sred;
- for(int i = 0; i < stan; i++)
- {
- cout << "Podaj nazwisko: ";
- gets(kadra[i].nazwisko);
- cout << "Podaj wyplate: ";
- cin >> kadra[i].wyplata;
- cout << "Podaj wiek: ";
- cin >> kadra[i].wiek;
- cin.ignore();
- }
- if (!suma(kadra, stan, &su, &sred))
- cout << "Brak elementow";
- else
- {
- cout << "Suma wyplat: " << su << endl;
- cout << "Srednia wyplat: " << sred;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement