Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <windows.h>
- using namespace std;
- struct sportsman {
- char familya[80];
- char name[80];
- char otchestvo[80];
- char type[80];
- int year;
- };
- int min_year (sportsman *a, int n) {
- int min_y = a->year;
- for (int i = 0; i < n; i++)
- if (a[i].year < min_y) min_y = a[i].year;
- return min_y;
- }
- int search(const sportsman* a, const int n, int pos, const int input) {
- while (a[pos].year != input && pos < n) pos++;
- return pos;
- }
- void print (const sportsman &a) {
- cout << a.familya << " " << a.name[0] << " " << a.otchestvo[0];
- }
- int main() {
- SetConsoleCP (1251);
- SetConsoleOutputCP (1251);
- int n = 4;
- sportsman playoff[n] = {
- {"ергей", "резяпкин", "дмитриевич", "футбол", 1998 },
- {"алексей", "качаев", "владимирович", "футбол", 1980 },
- {"макар", "степин", "алксандровивич", "футбол", 2000},
- {"богдан", "петрович", "владимирович", "футбол", 1980}
- };
- int min = min_year(playoff, n);
- int pos = search(playoff,n,0,min);
- while (pos!=n) {
- print(playoff[pos]); cout << endl;
- pos = search(playoff,n,pos+1,min);
- }
- }
Add Comment
Please, Sign In to add comment