Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. struct human {
  5.     char name[50];
  6.     char lastName[50];
  7.     int birthDate;
  8. };
  9.  
  10. int main() {
  11.         struct human humList1[4], humList2[4], humListTemp[4];
  12.         for (int i = 0; i < 4; i++) {
  13.             printf(" Vvedite imya %d human\n", i + 1);
  14.             scanf("%s", humList1[i].name);
  15.  
  16.             printf("\n Vvedite familiu %d human\n", i + 1);
  17.             scanf("%s", humList1[i].lastName);
  18.  
  19.             printf("\n Vvedite vozrast %d human\n", i + 1);
  20.             scanf("%d", &humList1[i].birthDate);
  21.         }
  22.         for (int i = 0; i < 4; i++) {
  23.             for (int j = 3; j >= (i + 1); j--) {
  24.                 if (humList1[j].birthDate < humList1[j - 1].birthDate) {
  25.                     humListTemp[i] = humList1[j];
  26.                     humList1[j] = humList1[j - 1];
  27.                     humList1[j - 1] = humListTemp[i];
  28.                 }
  29.             }
  30.             humList2[i] = humList1[i];
  31.             printf("%s %s %d\n", humList2[i].name, humList2[i].lastName, humList2[i].birthDate);
  32.         }
  33.     getchar(); getchar();
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement