SHARE
TWEET

Untitled

a guest Oct 19th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include "stdio.h"
  3.  
  4.  
  5. using namespace std;
  6.  
  7. struct pracownik
  8. {
  9.     char nazwisko[25];
  10.     float wyplata;
  11.     int wiek;
  12. };
  13.  
  14. bool suma(pracownik t[], int ile, float *s, float *sr)
  15. {
  16.     if(ile <= 0)
  17.         return 0;
  18.  
  19.     *s = 0;
  20.  
  21.     for(int i = 0; i < ile; i++)
  22.         *s += t[i].wyplata;
  23.     *sr = *s/ile;
  24.  
  25.     return 1;
  26. }
  27.  
  28. int main()
  29. {
  30.     int stan = 3;
  31.     pracownik kadra[stan];
  32.     float su, sred;
  33.     for(int i = 0; i < stan; i++)
  34.         {
  35.             cout << "Podaj nazwisko: ";
  36.             gets(kadra[i].nazwisko);
  37.             cout << "Podaj wyplate: ";
  38.             cin >> kadra[i].wyplata;
  39.             cout << "Podaj wiek: ";
  40.             cin >> kadra[i].wiek;
  41.             cin.ignore();
  42.         }
  43.         if (!suma(kadra, stan, &su, &sred))
  44.             cout << "Brak elementow";
  45.         else
  46.         {
  47.             cout << "Suma wyplat: " << su << endl;
  48.             cout << "Srednia wyplat: " << sred;
  49.         }
  50. return 0;
  51.  
  52. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top