Advertisement
MadCortez

Untitled

Mar 25th, 2021
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. struct patient {
  6. char secName[15];
  7. char sex[7];
  8. int age;
  9. char city[15];
  10. char diagnosis[15];
  11. };
  12.  
  13. using namespace std;
  14.  
  15. int inputSize() {
  16. int n;
  17. cout << "Введите кол-во пациентов: ";
  18. cin >> n;
  19. return n;
  20. }
  21.  
  22. patient* inputArr(int n) {
  23. cout << "Введите данные о пациентах" << endl;
  24. patient* data = new patient[n];
  25. for (int i = 0; i < n; i++) {
  26. cout << "Фамилия " << i + 1 << " пациента: ";
  27. cin >> (data + i)->secName;
  28. cout << "Пол " << i + 1 << " пациента: ";
  29. cin >> (data + i)->sex;
  30. cout << "Возраст " << i + 1 << " пациента: ";
  31. cin >> (data + i)->age;
  32. cout << "Город " << i + 1 << " пациента: ";
  33. cin >> (data + i)->city;
  34. cout << "Диагноз " << i + 1 << " пациента: ";
  35. cin >> (data + i)->diagnosis;
  36. cout << endl;
  37. }
  38. return data;
  39. delete(data);
  40. }
  41.  
  42. void printInfo(patient* arr, int n) {
  43. for (int i = 0; i < n; i++) {
  44. cout << "Пациент " << i + 1 << ": " ;
  45. cout << (arr + i)->secName << " " << (arr + i)->sex << " " << (arr + i)->age << " " << (arr + i)->city << " "
  46. << (arr + i)->diagnosis << endl;
  47. }
  48. }
  49.  
  50. void printAns(patient* arr, int n) {
  51. vector <patient> ans;
  52. for (int i = 0; i < n; i++)
  53. if ((arr + i)->city[0] == 'M' && (arr + i)->city[1] == 'i' && (arr + i)->city[2] == 'n' && (arr + i)->city[3] == 's'
  54. && (arr + i)->city[4] == 'k')
  55. ;
  56. else
  57. ans.push_back(arr[i]);
  58. cout << endl;
  59. cout << "Кол-во иногородних пациентов: " << ans.size() << endl;
  60. for (int i = 0; i < ans.size(); i++)
  61. cout << ans[i].secName << " " << ans[i].sex << " " << ans[i].age << " " << ans[i].city << " " << ans[i].diagnosis << endl;
  62. }
  63.  
  64. int main()
  65. {
  66. setlocale(LC_ALL, "Russian");
  67. int n = inputSize();
  68. patient* arr = new patient[n];
  69. arr = inputArr(n);
  70. printInfo(arr, n);
  71. printAns(arr, n);
  72. delete(arr);
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement