#include <iostream>
#include <string>
using namespace std;
struct Animal {
string name;
string species;
string color;
int age;
double weight;
};
void showAnimal(Animal a) {
cout << "Имя: " << a.name << endl;
cout << "Вид: " << a.species << endl;
cout << "Окрас: " << a.color << endl;
cout << "Возраст: " << a.age << " лет" << endl;
cout << "Вес: " << a.weight << " кг" << endl;
cout << "------------------------" << endl;
}
void renameAnimal(Animal &a, string newName) {
a.name = newName;
cout << "Новое имя: " << newName << endl;
}
void feedAnimal(Animal &a, int days) {
double gain = a.weight * 0.01 * days;
a.weight += gain;
cout << "Покормили " << days << " дней. Прибавка: " << gain << " кг" << endl;
}
int main() {
setlocale(LC_ALL, "Russian");
cout << "=== Статический объект ===" << endl;
Animal cat;
cat.name = "Барсик";
cat.species = "Кот";
cat.color = "Рыжий";
cat.age = 3;
cat.weight = 5.0;
showAnimal(cat);
renameAnimal(cat, "Мурзик");
feedAnimal(cat, 10);
cout << "Текущий вес: " << cat.weight << " кг" << endl;
cout << endl;
cout << "=== Динамический объект ===" << endl;
Animal* dog = new Animal();
dog->name = "Шарик";
dog->species = "Собака";
dog->color = "Черный";
dog->age = 5;
dog->weight = 15.5;
showAnimal(*dog);
renameAnimal(*dog, "Бобик");
feedAnimal(*dog, 5);
cout << "Текущий вес: " << dog->weight << " кг" << endl;
delete dog;
return 0;
}