Advertisement
LabiinfaCibGyti

laba9.17

Jan 9th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.72 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. {
  34.     printf("|%2d|%13s|%2s |     %5d    | %4d |\n",
  35. z[i].num,z[i].fio, z[i].pol, z[i].voz,z[i].stag);}
  36. printf("--------------------------------------------\n");
  37. for (i=0;i<n;i++)
  38.  {
  39.      if (z[i].pol[0]=='Ж')
  40.  y[k++]=z[i];
  41. }
  42. for(i=1;i<k;i++)
  43. {
  44.  for(j=k-1;j>=i;j--)
  45.  {
  46.  if(y[j].stag>y[j-1].stag)
  47.  {
  48.      x=y[j];
  49.  y[j]=y[j-1];
  50.  y[j-1]=x;
  51.  }}}
  52.  printf("По стажу\n");
  53. printf("--------------------------------------------\n");
  54. printf("| №|     ФИО     |Пол| Год рождения | Стаж |\n");
  55. printf("--------------------------------------------\n");
  56.  
  57. for (i=0;i<k;i++)
  58. {
  59.     printf("|%2d|%13s|%2s |     %5d    | %4d |\n",
  60. y[i].num,y[i].fio, y[i].pol, y[i].voz,y[i].stag);
  61. }
  62. printf("--------------------------------------------\n");
  63. return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement