коментар
потрібно написати коментарі для коду і описати як він працює.
сам код
#include <iostream>
#include <string>
using namespace std;
class info
{
public:
virtual void show() = 0;
};
class unit : public info
{
public:
unit * parent = NULL;
unit *next = NULL,
*next2 = NULL;
string name,
secondName,
IDCode,
age;
unit(string _n, string _sn, string _ID, string _a)
{
name = _n;
secondName = _sn;
IDCode = _ID;
age = _a;
}
unit(string _n, string _sn, string _ID, string _a, unit *_p)
{
name = _n;
secondName = _sn;
IDCode = _ID;
age = _a;
parent = _p;
}
void init_next(string _n, string _sn, string _ID, string _a)
{
next = new unit(_n, _sn, _ID, _a, this);
}
void init_next2(string _n, string _sn, string _ID, string _a)
{
next2 = new unit(_n, _sn, _ID, _a, this);
}
void show_once()
{
cout << name << " " << secondName << " " << IDCode << " " << age << endl;
}
void show()
{
show_once();
if (next != NULL)
{
next->show();
}
if (next2 != NULL)
{
next2->show();
}
}
unit search(string _n, string _sn)
{
if ((name == _n) && (secondName == _sn))
{
return *this;
}
else if (next != NULL || next2 != NULL)
{
if (next != NULL)
{
return next->search(_n, _sn);
}
if (next2 != NULL)
{
return next2->search(_n, _sn);
}
}
else
{
cout << "Нічого невдалось знайти по вашому запиту " << endl;
}
}
};
void dialogmenu(unit _m)
{
int temp;
system ("chcp 1251> nul");
cout << "Існуюче генеалогічне дерево" << _m.name << endl;
cout << "1. Створити нове генеалогічне дерево.\n2.Показати існуюче генеалогічне дерево\n3.Пошук по існуючому генеалогічному дереві\n4.Добавити ліву гілку генеалогічного дерева\n5.Добавити праву гілку генеалогічного дерева\n";
cin >> temp;
switch(temp)
{
case 1:
{
string name;
string secondName;
string IDCode;
string age;
cout << "Input name" << endl;
cin >> name;
cout << "Input sName" << endl;
cin >> secondName;
cout << "input ID" << endl;
cin >> IDCode;
cout << "input age" << endl;
cin >> age;
unit nUnit(name, secondName, IDCode, age);
dialogmenu(nUnit);
break;
}
case 3:
{
string tempname, tempSName;
cout << "Введіть імя яке потрібно знайти" << endl;
cin >> tempname;
cout << "Введіть прізвище яке потрібно знайти" << endl;
cin >> tempSName;
_m.search(tempname, tempSName);
break;
}
case 4:
{
string name;
string secondName;
string IDCode;
string age;
cout << "Input name" << endl;
cin >> name;
cout << "Input sName" << endl;
cin >> secondName;
cout << "input ID" << endl;
cin >> IDCode;
cout << "input age" << endl;
cin >> age;
_m.init_next(name, secondName, IDCode, age);
break;
}
case 5:
{
string name;
string secondName;
string IDCode;
string age;
cout << "Input name" << endl;
cin >> name;
cout << "Input sName" << endl;
cin >> secondName;
cout << "input ID" << endl;
cin >> IDCode;
cout << "input age" << endl;
cin >> age;
_m.init_next2(name, secondName, IDCode, age);
break;
}
}
dialogmenu(_m);
}
int main()
{
unit main("Name1", "SecondNameOne", "ID1", "Age1");
main.init_next("Name2", "SecondName2", "ID2", "Age2");
main.init_next2("Name2-2", "SecondName2-2", "ID2-2", "Age2-2");
main.next->init_next("Name3", "SecondName3", "ID3", "Age3");
main.next->init_next2("Name3-2", "SecondName3-2", "ID3-2", "Age3-2");
main.next2->init_next("Name4", "SecondName4", "ID4", "Age4");
main.next2->init_next2("Name4-2", "SecondName4-2", "ID4-2", "Age4-2");
dialogmenu(main);
system("pause");
return 0;
}
-
179 1 0 Здравствуйте, готова прокомментировать каждую строчку кода, к вечеру будет готово, буду рада помочь)
-
106 Сделаю за 1 день. Напишу подробно комментарии к каждой строке кода.
-
337 5 0 Здраствуйте. Могу Вам помочь. Обращайтесь. Проффесионально занимаюсь разаботкой софта.
-
810 40 0 Здравствуйте, прокомментиру подробно этот код, не проблема, буду рад помочь
-
Тю!
Прокоментуєш прості стрічки з оголошенням змінних, присвоєнням значень, вводом/виводом данних і від коду нічого не залишиться.
Очі бояться, а руки роблять. -
Current freelance projects in the category C & C++
Residential Proxy Infrastructure EngineerWe're building a residential proxy network from scratch — fully owned, no third-party suppliers. We need one exceptional network engineer to build the entire technical foundation. What you'll build: - Android background SDK that routes proxy traffic through user devices… C & C++, DevOps ∙ 3 days 19 hours back ∙ 13 proposals |
Improvement in the existing version of 1C retail block for the distribution center (DC)In general, I will explain what kind of database we have - There is a main server where there is a retail database (where all receipts are recorded) - a UTP database - where all sales are transferred - it calculates the markup and stock balances - small databases of retail… C & C++, C# ∙ 4 days 9 hours back ∙ 6 proposals |
About the Master Program "KONSTRUCTOR"
4182 USD
We are looking for a very experienced C++ developer to modernize existing software (master program). The program is responsible for creating derivative software representing audio-visual sessions of psychological correction. The current version is written in pure WinAPI (Visual… C & C++, Desktop Apps ∙ 9 days 12 hours back ∙ 19 proposals |
Writing code for ArduinoIt is necessary to develop software for a weight dispenser based on Arduino Uno. Components: Arduino Uno R3 HX711 + load cell LCD1602 I2C display MAX7219 LED matrix 8x32 5 control buttons 4-channel relay 2 signal lamps Coarse dosing vibrator Precise dosing vibrator Operation… C & C++, Embedded Systems & Microcontrollers ∙ 10 days 21 hours back ∙ 15 proposals |
It is necessary to complete the project or provide consultation.
23 USD
|