Untitled
unknown
plain_text
3 years ago
2.1 kB
8
Indexable
#include <iostream>
#include <string>
#include <Windows.h>
using namespace std;
struct forest
{
int id; // Номер участка
double area; // Площадь лесного участка
int treesCount; // Количество деревьев на участке
string type; // Тип леса (широколиственный-broadleaf, хвойный-coniferous, смешанный-mixed)
bool hasProtectedZones; // Наличие природоохранных зон
};
void GetData(forest* list, int amount)
{
for (int i = 0; i < amount; i++)
{
cout << "Введите номер участка" << "\n";
cin >> list[i].id;
cout << "Введите площадь участка" << "\n";
cin >> list[i].area;
cout << "Введите количество деревьев на участке" << "\n";
cin >> list[i].treesCount;
cout << "Введите тип лесного участка" << "\n";
cin >> list[i].type;
cout << "Есть ли у участка природоохранная зона (0 - нет, 1 - да)" << "\n";
cin >> list[i].hasProtectedZones;
}
cout << "\n";
}
void ShowData(forest* list, int amount)
{
cout << "Номер - Площадь - Кол-во деревьев - Тип - Наличие природоохранной зоны" << endl;
for (int i = 0; i < amount; i++)
{
if (list[i].area >= 1000 && list[i].type == "mixed" && list[i].hasProtectedZones == 1)
cout << list[i].id << " - " << list[i].area << " - " << list[i].treesCount << " - "
<< list[i].type << " - " << list[i].hasProtectedZones << endl;
}
}
void main()
{
SetConsoleCP(1251);
setlocale(LC_ALL, "Russian");
int n;
cout << "Колличество лесных зон - ";
cin >> n;
forest* list = new forest[n];
GetData(list, n);
ShowData(list, n);
delete[]list;
}Editor is loading...