Guest User

Untitled

a guest
Nov 23rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.63 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4. #include <stdio.h>
  5. #include <windows.h>
  6. #include <conio.h>
  7.  
  8. using namespace std;
  9. int p[4];
  10. void space(int *x1, int *x2, int *x3, int *x4, int x5) { //Вычисление кол-ва пробелов в таблице
  11. if ((*x1 >= *x2) && (*x1 >= *x3) && (*x1 >= *x4) && (*x1 >= x5)) {
  12. p[0] = 3;
  13. for (p[1] = 1; p[1] < *x1 + 3 - *x2; p[1]++);
  14. for (p[2] = 1; p[2] < *x1 + 3 - *x3; p[2]++);
  15. for (p[3] = 1; p[3] < *x1 + 3 - *x4; p[3]++);
  16. for (p[4] = 1; p[4] < *x1 + 3 - x5; p[4]++);
  17. }
  18. if ((*x2 >= *x1) && (*x2 >= *x3) && (*x2 >= *x4) && (*x2 >= x5)) {
  19. p[1] = 3;
  20. for (p[0] = 1; p[0] < *x2 + 3 - *x1; p[0]++);
  21. for (p[2] = 1; p[2] < *x2 + 3 - *x3; p[2]++);
  22. for (p[3] = 1; p[3] < *x2 + 3 - *x4; p[3]++);
  23. for (p[4] = 1; p[4] < *x2 + 3 - x5; p[4]++);
  24. }
  25. if ((*x3 >= *x1) && (*x3 >= *x2) && (*x3 >= *x4) && (*x3 >= x5)) {
  26. p[2] = 3;
  27. for (p[0] = 1; p[0] < *x3 + 3 - *x1; p[0]++);
  28. for (p[1] = 1; p[1] < *x3 + 3 - *x2; p[1]++);
  29. for (p[3] = 1; p[3] < *x3 + 3 - *x4; p[3]++);
  30. for (p[4] = 1; p[4] < *x3 + 3 - x5; p[4]++);
  31. }
  32. if ((*x4 >= *x1) && (*x4 >= *x3) && (*x4 >= *x2) && (*x4 >= x5)) {
  33. p[3] = 3;
  34. for (p[0] = 1; p[0] < *x4 + 3 - *x1; p[0]++);
  35. for (p[2] = 1; p[2] < *x4 + 3 - *x3; p[2]++);
  36. for (p[1] = 1; p[1] < *x4 + 3 - *x2; p[1]++);
  37. for (p[4] = 1; p[4] < *x4 + 3 - x5; p[4]++);
  38. }
  39. if ((x5 >= *x1) && (x5 >= *x3) && (x5 >= *x2) && (x5 >= *x4)) {
  40. p[4] = 3;
  41. for (p[0] = 1; p[0] < x5 + 3 - *x1; p[0]++);
  42. for (p[2] = 1; p[2] < x5 + 3 - *x3; p[2]++);
  43. for (p[1] = 1; p[1] < x5 + 3 - *x2; p[1]++);
  44. for (p[4] = 1; p[4] < x5 + 3 - *x4; p[3]++);
  45. };
  46. }
  47.  
  48. struct man //Структура для хранения информации о людях
  49. {
  50. string fname;
  51. string sname;
  52. string fathername;
  53. int d, m, y, a;
  54.  
  55. } ch[4];
  56.  
  57. int a2(int year, int day, int mounth) { //Вычисление возраста
  58. SYSTEMTIME st;
  59. GetSystemTime(&st);
  60. int age = st.wYear - year;
  61. if (mounth > st.wMonth)
  62. if (day > st.wDay)
  63. age--;
  64. return age;
  65. }
  66.  
  67. void out(string *name, string *sname, string *fname, int o, int f, int s, int *d, int *y, int *m, int *a) { //Вывод таблицы на экран
  68. setlocale(LC_ALL, "rus");
  69. cout << *sname;
  70. for (int i = 0; i < s; i++)
  71. cout << " ";
  72.  
  73. cout << *name;
  74. for (int i = 0; i < f; i++)
  75. cout << " ";
  76.  
  77. cout << *fname;
  78. for (int i = 0; i < o; i++)
  79. cout << " ";
  80.  
  81. printf("%02u.%02u.%u %un", *d, *m, *y, *a);
  82. }
  83.  
  84. void in(int d, int m, int y, int i) { //Передача данных о дате рождения в структуру и вычисление возраста
  85.  
  86. ch[i].d = d;
  87. ch[i].m = m;
  88. ch[i].y = y;
  89. ch[i].a = a2(ch[i].y, ch[i].d, ch[i].m);
  90.  
  91. };
  92.  
  93. int main()
  94. {
  95. int n[4], f[5], o[5], s[5];
  96. setlocale(LC_ALL, "rus");
  97.  
  98. ch[0].fname = "Иван";
  99. ch[0].sname = "Гармашев";
  100. ch[0].fathername = "Юрьевич";
  101. ch[1].fname = "Андрей";
  102. ch[1].sname = "Крикливый";
  103. ch[1].fathername = "Николаевич";
  104. ch[2].fname = "Илья";
  105. ch[2].sname = "Ковалев";
  106. ch[2].fathername = "Александрович";
  107. ch[3].fname = "Владислав";
  108. ch[3].sname = "Дмитриев";
  109. ch[3].fathername = "Артёмович";
  110. in(04, 04, 2000, 0);
  111. in(29, 11, 1999, 1);
  112. in(12, 02, 1998, 2);
  113. in(30, 10, 2000, 3);
  114.  
  115. for (int i = 0; i < 4; i++)
  116. n[i] = ch[i].fname.size();
  117. space(&n[0], &n[1], &n[2], &n[3], 3);
  118. for (int i = 0; i < 5; i++)
  119. f[i] = p[i];
  120.  
  121. for (int i = 0; i < 4; i++)
  122. n[i] = ch[i].sname.size();
  123. space(&n[0], &n[1], &n[2], &n[3], 7);
  124. for (int i = 0; i < 5; i++)
  125. s[i] = p[i];
  126.  
  127. for (int i = 0; i < 4; i++)
  128. n[i] = ch[i].fathername.size();
  129. space(&n[0], &n[1], &n[2], &n[3], 8);
  130. for (int i = 0; i < 5; i++)
  131. o[i] = p[i];
  132.  
  133. printf("Бригада №3nnКоличество членов бригады: 4nnФамилия");
  134. for (int i = 0; i < s[4]; i++)
  135. cout << " ";
  136.  
  137. cout << "Имя";
  138. for (int i = 0; i < f[4]; i++)
  139. cout << " ";
  140.  
  141. cout << "Отчество";
  142. for (int i = 0; i < o[4]; i++)
  143. cout << " ";
  144.  
  145. cout << "Дата Возраст";
  146. cout << endl;
  147. for (int i = 0; i < 4; i++)
  148. out(&ch[i].fname, &ch[i].sname, &ch[i].fathername, o[i], f[i], s[i], &ch[i].d, &ch[i].y, &ch[i].m, &ch[i].a);
  149. system("pause");
  150.  
  151. return 0;
  152. }
Add Comment
Please, Sign In to add comment