
#include <bits/stdc++.h>
#define M_PI 3.1415926
using namespace std;
class Shape {
public:
virtual double area() = 0; // 定义纯虚函数area
};
class Circle : public Shape {
public:
double radius;
Circle(double r) : radius(r) {}
double area() override {
return M_PI * radius * radius;
}
};
class Square : public Shape {
public:
double side;
Square(double s) : side(s) {}
double area() override {
return side * side;
}
};
class Rectangle : public Shape {
public:
double length;
double width;
Rectangle(double l, double w) : length(l), width(w) {}
double area() override {
return length * width;
}
};
int main()
{
int t;
cin >> t;
while (t--)
{
double r, l, ll, w;
cin >> r >> l >> ll >> w;
cout << fixed << setprecision(2);
Circle ci(r);
cout << ci.area() << '\n';
Square sq(l);
cout << sq.area() << '\n';
Rectangle rc(ll, w);
cout << rc.area() << '\n';
}
return 0;
}

#include <bits/stdc++.h>
using namespace std;
class Vehicle
{
protected:
string no; //编号
public:
Vehicle() : no("accept") {}
Vehicle(string s) : no(s) {} // 添加一个构造函数来初始化no
virtual void display() = 0; //应收费用
};
class Car : public Vehicle {
public:
int people, weight;
Car(string s, int people, int weight) : Vehicle(s),people(people),weight(weight) {}
void display() override {
cout << no << " " << people * 8 + weight * 2 << endl;
}
};
class Truck : public Vehicle {
public:
int weight;
Truck(string s, int weight) : Vehicle(s),weight(weight) {}
void display() override {
cout << no << " " << weight * 5 << endl;
}
};
class Bus : public Vehicle {
public:
int people;
Bus(string s, int people) : Vehicle(s), people(people) {}
void display() override {
cout << no << " " << people * 30 << endl;
}
};
int main()
{
Vehicle* pv = nullptr;
int t;
cin >> t;
while (t--)
{
int type;
cin >> type;
string s;
cin >> s;
if (type == 1)
{
int people, weight;
cin >> people >> weight;
pv = new Car(s, people, weight);
}
else if (type == 2)
{
int weight;
cin >> weight;
pv = new Truck(s, weight);
}
else
{
int people;
cin >> people;
pv = new Bus(s, people);
}
pv->display();
}
delete pv;
return 0;
}

#include <bits/stdc++.h>
using namespace std;
class BaseAccount
{
protected:
string name;
string card;
int balance;
public:
BaseAccount(string name,string card,int balance) : name(name),card(card),balance(balance) {}
virtual void deposit(int cun)
{
balance += cun;
}
virtual void withdraw(int qv)
{
if (balance < qv)
{
cout << "insufficient" << '\n';
}
else
{
balance -= qv;
}
}
virtual void display()
{
cout << name << " " << card << " Balance:" << balance << '\n';
}
};
class BasePlus : public BaseAccount
{
public:
BasePlus(string name, string card, int balance) : BaseAccount(name, card, balance) {}
int limitSum = 5000;
void deposit (int cun) override
{
balance += cun;
}
void withdraw (int qv) override
{
if (balance + 5000 < qv)
{
cout << "insufficient" << '\n';
}
else
{
balance -= qv;
}
}
void display() override
{
if (balance < 0)
{
limitSum += balance;
balance = 0;
}
cout << name << " " << card << " Balance:" << balance << " ";
cout << "limit:" << limitSum << '\n';
}
};
int main()
{
BaseAccount* p = nullptr;
int t;
cin >> t;
while (t--)
{
string name, card;
cin >> name >> card;
int accout;
cin >> accout;
if (card[1] == 'A')
{
p = new BaseAccount(name, card, accout);
int num = 2;
while (num--)
{
int cun;
cin >> cun;
p->deposit(cun);
int qv;
cin >> qv;
p->withdraw(qv);
}
}
else
{
p = new BasePlus(name, card, accout);
int num = 2;
while (num--)
{
int cun;
cin >> cun;
p->deposit(cun);
int qv;
cin >> qv;
p->withdraw(qv);
}
}
p->display();
}
delete p;
return 0;
}

#include <bits/stdc++.h>
using namespace std;
class Group
{
public:
virtual int add(int x, int y) = 0; // 输出加法的运算结果
virtual int sub(int x, int y) = 0; // 输出减法的运算结果
};
class GroupA : public Group {
public:
int add(int x, int y) override {
return x + y;
}
int sub(int x, int y) override {
return x - y;
}
};
class GroupB : public Group {
public:
int add(int x, int y) override {
return x + y;
}
int sub(int x, int y) override {
int ans = 0;
int xx = x;
int yy = y;
int wei = 1;
while (xx > 0 || yy > 0){
int mid1 = xx % 10;
int mid2 = yy % 10;
if (mid1 < mid2)
{
mid1 += 10;
}
ans += (mid1 - mid2) * wei;
wei *= 10;
xx /= 10;
yy /= 10;
}
return ans;
}
};
class GroupC : public Group {
public:
int add(int x, int y) override {
int ans = 0;
int xx = x;
int yy = y;
int wei = 1;
while (xx > 0 || yy > 0) {
int mid1 = xx % 10;
int mid2 = yy % 10;
ans += ((mid1 + mid2) % 10) * wei;
xx /= 10;
yy /= 10;
wei *= 10;
}
return ans;
}
int sub(int x, int y) override {
int ans = 0;
int xx = x;
int yy = y;
int wei = 1;
while (xx > 0 || yy > 0) {
int mid1 = xx % 10;
int mid2 = yy % 10;
if (mid1 < mid2)
{
mid1 += 10;
}
ans += abs(mid1 - mid2) * wei;
wei *= 10;
xx /= 10;
yy /= 10;
}
return ans;
}
};
int main()
{
int t;
cin >> t;
while (t--)
{
int type, x, y;
char s;
cin >> type >> x >> s >> y;
Group* st = nullptr;
if (type == 1)
{
st = new GroupA();
}
else if (type == 2)
{
st = new GroupB();
}
else
{
st = new GroupC();
}
if (s == '+')
{
cout << st->add(x, y) << '\n';
}
else
{
cout << st->sub(x, y) << '\n';
}
delete st;
}
return 0;
}

#include <bits/stdc++.h>
using namespace std;
class Animal
{
protected:
string name;
int age;
public:
Animal(string name, int age) : name(name), age(age) {}
virtual void Speak() {
cout << "accept" << '\n';
}
};
class Tiger : public Animal
{
public:
Tiger(string name, int age) : Animal(name, age) {}
void Speak() override {
cout << "Hello,I am " << name << ",AOOO." << '\n';
}
};
class Dog : public Animal
{
public:
Dog(string name, int age) : Animal(name, age) {}
void Speak() override {
cout << "Hello,I am " << name << ",WangWang." << '\n';
}
};
class Duck : public Animal
{
public:
Duck(string name, int age) : Animal(name, age) {}
void Speak() override {
cout << "Hello,I am " << name << ",GAGA." << '\n';
}
};
class Pig : public Animal
{
public:
Pig(string name, int age) : Animal(name, age) {}
void Speak() override {
cout << "Hello,I am " << name << ",HENGHENG." << '\n';
}
};
int main()
{
int t;
cin >> t;
string a, b, c, d;
a = "Tiger";
b = "Dog";
c = "Duck";
d = "Pig";
while (t--)
{
Animal* an = nullptr;
string title, name;
int age;
cin >> title >> name >> age;
if (title != a && title != b && title != c && title != d)
{
cout << "There is no " << title << " in our Zoo." << '\n';
continue;
}
else
{
if (title == a) {
an = new Tiger(name, age);
}
else if (title == b) {
an = new Dog(name, age);
}
else if (title == c) {
an = new Duck(name, age);
}
else if (title == d) {
an = new Pig(name, age);
}
an->Speak();
delete an;
}
}
return 0;
}