Advertisement
LabiinfaCibGyti

laba9.16

Dec 11th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <math.h>
  4. #include<conio.h>
  5. #include<stdlib.h>
  6. typedef struct abon
  7. {   int num;
  8.     char fio[20], pol[20];
  9.  int voz, stag;
  10. }ABON;
  11. const int n=10;
  12. int i,k,j;
  13. int main()
  14. {
  15.     setlocale(0,"rus");
  16.     ABON z[n]={
  17. {1,"Анисимов Ю.П.","М",1940,1957},
  18. {2,"Иванов И.Н.  ","М",1980,1999},
  19. {3,"Махова О.И.  ","Ж",1960,1980},
  20. {4,"Огарев К.М.  ","М",1971,1990},
  21. {5,"Егорова П.К. ","Ж",1993,2011},
  22. {6,"Голикова О.И.","Ж",1972,1990},
  23. {7,"Сотников Т.С.","М",1980,1999},
  24. {8,"Комов В.И.   ","М",1979,2005},
  25. {9,"Лебедев А.А. ","М",1959,1981},
  26. {10,"Димова В.В. ","Ж",1991,2010},
  27. },y[n];
  28.  ABON x;
  29. printf("--------------------------------------------\n");
  30. printf("| №|     ФИО     |Пол| Год рождения | Стаж |\n");
  31. printf("--------------------------------------------\n");
  32. for (i=0;i<n;i++)
  33. {printf("|%2d|%13s|%2s |     %5d    | %4d |\n",
  34. z[i].num,z[i].fio, z[i].pol, z[i].voz,z[i].stag);}
  35. printf("--------------------------------------------\n");
  36. for (i=0;i<n;i++)
  37.  {
  38.      if (z[i].voz>1979)
  39.  y[k++]=z[i];
  40. }
  41. for(i=1;i<k;i++)
  42. {
  43.  for(j=k-1;j>=i;j--)
  44.  {
  45.  if(y[j].stag<y[j-1].stag)
  46.  {
  47.      x=y[j];
  48.  y[j]=y[j-1];
  49.  y[j-1]=x;
  50.  }}}
  51.  printf("По стажу\n");
  52. printf("--------------------------------------------\n");
  53. printf("| №|     ФИО     |Пол| Год рождения | Стаж |\n");
  54. printf("--------------------------------------------\n");
  55.  
  56. for (i=0;i<k;i++)
  57. {
  58.     printf("|%2d|%13s|%2s |     %5d    | %4d |\n",
  59. y[i].num,y[i].fio, y[i].pol, y[i].voz,y[i].stag);
  60. }
  61. printf("--------------------------------------------\n");
  62. return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement