Advertisement
LabiinfaCibGyti

laba9.9

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