Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <list>
- using namespace std;
- struct patient : public error_code {
- patient() {
- }
- patient(string firstName, string secondName, string gender,
- string age, string address, string tNumber, string date) {
- this->firstName = firstName;
- this->secondName = secondName;
- this->gender = gender;
- this->age = age;
- this->address = address;
- this->tNumber = tNumber;
- this->date = date;
- }
- private:
- string firstName;
- string secondName;
- string gender;
- string age;
- string address;
- string tNumber;
- string date;
- public:
- string getFirstName() {
- return firstName;
- }
- string getSecondName() {
- return secondName;
- }
- string getGender() {
- return gender;
- }
- string getAge() {
- return age;
- }
- /*int searchYoungAges(patient *pt) {
- for (int i = 0; i < 100; i++) {
- if (pt[i].age < 18) {
- return i;
- }
- }
- return 0;
- }
- */
- void printInformation(patient *pt) {
- for (int i = 0; i < 5; i++) {
- cout << "Имя: " << pt[i].firstName << endl;
- cout << "Фамилия: " << pt[i].secondName << endl;
- cout << "Пол: " << pt[i].gender << endl;
- cout << "Возраст: " << pt[i].age << endl;
- cout << "Адрес: " << pt[i].address << endl;
- cout << "Номер телефона: " << pt[i].tNumber << endl;
- cout << "Дата последнего обращения: " << pt[i].date << endl;
- cout << "\n" << endl;
- }
- }
- };
- int main() {
- cout << "Введите название файла для чтения: ";
- string filenameinput;
- cin >> filenameinput;
- ifstream input;
- input.open(filenameinput + ".txt");
- //ifstream input(filenameinput + ".txt");
- if (!input.is_open()) {
- cout << "Ошибка при открытии файла чтения!" << endl;
- return -1;
- }
- else {
- cout << "Файл чтения открылся" << endl;
- }
- cout << "Введите название файла для записи: ";
- string filenameoutput;
- cin >> filenameoutput;
- ofstream output;
- output.open(filenameoutput + ".txt");
- //ofstream output(filenameoutput + ".txt");
- if (!input.is_open()) {
- cout << "Ошибка при открытии файла записи!" << endl;
- return -1;
- }
- else {
- cout << "Файл записи открылся" << endl;
- }
- string strOfLine;
- struct patient arr[50];
- string arr2[256];
- int i = 0;
- int i2 = 0;
- string strOfPatient;
- while (!input.eof()) {
- strOfLine = "";
- getline(input, strOfLine);
- strOfPatient += strOfLine + "\n";
- if (strOfLine != "") {
- arr2[i2] = strOfLine;
- i2++;
- }
- if (i2 == 6) {
- getline(input, strOfLine);
- strOfPatient += strOfLine + "\n";
- arr2[i2] = strOfLine;
- arr2[i] = strOfLine;
- i2 = 0;
- arr[i] = { arr2[0], arr2[1], arr2[2], arr2[3],
- arr2[4], arr2[5], arr2[6] };
- arr2[0] = "";
- arr2[1] = "";
- arr2[2] = "";
- arr2[3] = "";
- arr2[4] = "";
- arr2[5] = "";
- arr2[6] = "";
- strOfPatient = "";
- i++;
- }
- }
- input.close();
- int userChoice;
- string firstNameUser;
- string secondNameUser;
- string genderUser;
- string ageUser;
- string addressUser;
- string tNumberUser;
- string dateUser;
- while (i < 50) {
- cout << "Хотите добавить информацию о новом пациенте? (1-да/0-нет)" << endl;
- cin >> userChoice;
- if (userChoice == 1) {
- cout << "Введите имя пациента : ";
- cin >> firstNameUser;
- cout << "Введите фамилию пациента : ";
- cin >> secondNameUser;
- cout << "Введите пол пациента : ";
- cin >> genderUser;
- cout << "Введите возраст пациента : ";
- cin >> ageUser;
- cout << "Введите адрес пациента : ";
- cin >> addressUser;
- cout << "Введите контактный номер телефона пациента : ";
- cin >> tNumberUser;
- cout << "Введите последнюю дату обращения пациента в центр : ";
- cin >> ageUser;
- arr[i] = { firstNameUser, secondNameUser, genderUser,
- ageUser, addressUser, tNumberUser, ageUser };
- if (stoi(arr[i].getAge()) < 18) {
- output << firstNameUser;
- output << " ";
- output << secondNameUser;
- output << " ";
- output << genderUser;
- output << " ";
- output << ageUser;
- output << " ";
- output << tNumberUser;
- output << " ";
- output << ageUser;
- }
- i++;
- }
- else {
- break;
- }
- }
- output.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement