Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.47 KB | None | 0 0
  1. // Funkcje struct 3.cpp: Określa punkt wejścia dla aplikacji konsoli.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include<iostream>
  6. using namespace std;
  7. const int KMAX = 100;
  8.  
  9. struct dane
  10. {
  11.     char imię[40], nazwisko[50];
  12.     float zarobek;
  13. };
  14.  
  15. void wpis( int n,dane *(x))
  16. {
  17.     int i;
  18.     for (i = 0; i < n; i++)
  19.     {
  20.         cout << "Osoba nr " << i + 1 << endl;
  21.         cout << "Podaj imię: ";
  22.         cin >> x->imię;
  23.         cout << "Podaj nazwisko: ";
  24.         cin >> x->nazwisko;
  25.         cout << "Podaj zarobek: ";
  26.         cin >> x->zarobek;
  27.     }
  28. }
  29. void wypis(dane x[], int n)
  30. {
  31.     int i;
  32.     for (i = 0; i < n; i++)
  33.     {
  34.  
  35.         cout << "Osoba nr " << n + 1 << endl;
  36.         cout << "Imię: " << x[i].imię << endl;
  37.         cout << "Nazwisko: " << x[i].nazwisko << endl;
  38.         cout << "zarobek: " << x[i].zarobek << endl;
  39.     }
  40. }
  41. void wypisw(dane x)
  42. {
  43.     cout << "Osoba  "<< endl;
  44.     cout << "Imię: " << x.imię << endl;
  45.     cout << "Nazwisko: " << x.nazwisko << endl;
  46.     cout << "Stan konta: " << x.zarobek << endl;
  47. }
  48. dane bieda(dane A[], dane *w, int n)
  49. {
  50.     int i;
  51.     int max,min=0 ;
  52.     max = 0;
  53.     for (i = 0; i < n; i++)
  54.     {
  55.         if (A[i].zarobek>A[max].zarobek)
  56.             max = i;
  57.         else
  58.         if (A[i].zarobek < A[min].zarobek)
  59.             min = i;
  60.     }
  61.     *w = A[min];
  62.     return A[max];
  63.  
  64.  
  65.  
  66. }
  67. int _tmain(int argc, _TCHAR* argv[])
  68. {
  69.     int i,n;
  70.     dane W[KMAX];
  71.     dane MAX;
  72.     dane MIN;
  73.  
  74.     cout << "Funkcja coś robi xd" << endl;
  75.     cout << "Podaj liczbę osób:";
  76.     cin >> n;
  77.     wpis(n, W);
  78.     wypis(W, n);
  79.     MAX=bieda(W, &MIN, n);
  80.     wypisw(MIN);
  81.     wypisw(MAX);
  82.     return 0;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement