Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- struct patient {
- char secName[15];
- char sex[7];
- int age;
- char city[15];
- char diagnosis[15];
- };
- using namespace std;
- int inputSize() {
- int n;
- cout << "Введите кол-во пациентов: ";
- cin >> n;
- return n;
- }
- patient* inputArr(int n) {
- cout << "Введите данные о пациентах" << endl;
- patient* data = new patient[n];
- for (int i = 0; i < n; i++) {
- cout << "Фамилия " << i + 1 << " пациента: ";
- cin >> (data + i)->secName;
- cout << "Пол " << i + 1 << " пациента: ";
- cin >> (data + i)->sex;
- cout << "Возраст " << i + 1 << " пациента: ";
- cin >> (data + i)->age;
- cout << "Город " << i + 1 << " пациента: ";
- cin >> (data + i)->city;
- cout << "Диагноз " << i + 1 << " пациента: ";
- cin >> (data + i)->diagnosis;
- cout << endl;
- }
- return data;
- delete(data);
- }
- void printInfo(patient* arr, int n) {
- for (int i = 0; i < n; i++) {
- cout << "Пациент " << i + 1 << ": " ;
- cout << (arr + i)->secName << " " << (arr + i)->sex << " " << (arr + i)->age << " " << (arr + i)->city << " "
- << (arr + i)->diagnosis << endl;
- }
- }
- void printAns(patient* arr, int n) {
- vector <patient> ans;
- for (int i = 0; i < n; i++)
- if ((arr + i)->city[0] == 'M' && (arr + i)->city[1] == 'i' && (arr + i)->city[2] == 'n' && (arr + i)->city[3] == 's'
- && (arr + i)->city[4] == 'k')
- ;
- else
- ans.push_back(arr[i]);
- cout << endl;
- cout << "Кол-во иногородних пациентов: " << ans.size() << endl;
- for (int i = 0; i < ans.size(); i++)
- cout << ans[i].secName << " " << ans[i].sex << " " << ans[i].age << " " << ans[i].city << " " << ans[i].diagnosis << endl;
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- int n = inputSize();
- patient* arr = new patient[n];
- arr = inputArr(n);
- printInfo(arr, n);
- printAns(arr, n);
- delete(arr);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement