Advertisement
ostapdontstop

sergey

Jun 24th, 2018
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <windows.h>
  4. using namespace std;
  5.  
  6. struct sportsman {
  7.     char familya[80];
  8.     char name[80];
  9.     char otchestvo[80];
  10.     char type[80];
  11.     int year;
  12. };
  13. int min_year (sportsman *a, int n) {
  14.     int min_y = a->year;
  15.     for (int i = 0; i < n; i++)
  16.         if (a[i].year < min_y) min_y = a[i].year;
  17.     return min_y;
  18. }
  19. int search(const sportsman* a, const int n, int pos, const int input) {
  20.     while (a[pos].year != input && pos < n) pos++;
  21.     return pos;
  22. }
  23.  
  24. void print (const sportsman &a) {
  25.     cout << a.familya << " "  << a.name[0] << " "  << a.otchestvo[0];
  26. }
  27. int main() {
  28.     SetConsoleCP (1251);
  29.     SetConsoleOutputCP (1251);
  30.     int n = 4;
  31.     sportsman playoff[n] = {
  32.         {"ергей", "резяпкин", "дмитриевич", "футбол", 1998 },
  33.         {"алексей", "качаев", "владимирович", "футбол", 1980 },
  34.         {"макар", "степин", "алксандровивич", "футбол", 2000},
  35.         {"богдан", "петрович", "владимирович", "футбол", 1980}
  36.     };
  37.     int min = min_year(playoff, n);
  38.     int pos = search(playoff,n,0,min);
  39.     while (pos!=n) {
  40.         print(playoff[pos]); cout << endl;
  41.         pos = search(playoff,n,pos+1,min);
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement