#include<bits/stdc++.h>
using namespace std;
#define quc ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
int gcd(int a, int b)
{
return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b)
{
return a / gcd(a, b) * b;
}
class Point
{
private:
double x, y;
public:
Point();
Point(double x, double y);
double getX();
double getY();
void setX(double x_value);
void setY(double y_value);
double distanceToAnotherPoint(Point p);
};
Point::Point(double x, double y) : x(x), y(y) {}
double Point::distanceToAnotherPoint(Point p)
{
return sqrt(pow(x - p.x, 2) + pow(y - p.y, 2));
}
double Point::getX()
{
return this->x;
}
double Point::getY()
{
return this->y;
}
void Point::setX(double x_value)
{
this->x = x_value;
}
void Point::setY(double y_value)
{
this->y = y_value;
}
int main()
{
quc;
int t;
cin >> t;
while (t--)
{
double x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
Point p1(x1, y1), p2(x2, y2);
cout << "Distance of Point";
cout << '(' << fixed << setprecision(2) << p1.getX() << ',' << fixed << setprecision(2)<< p1.getY() << ')' << " " << "to Point(" << fixed << setprecision(2) << p2.getX() << ',' << fixed << setprecision(2) << p2.getY() << ')' << " is ";
cout << fixed << setprecision(2) << p1.distanceToAnotherPoint(p2) << endl;
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define quc ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
int gcd(int a, int b)
{
return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b)
{
return a / gcd(a, b) * b;
}
class Date
{
private:
int year, month, day;
public:
Date();
Date(int year, int month, int day);
void setDate(int year, int month, int day);
void addOneDay();
int getYear();
int getMonth();
int getDay();
void print();
bool isLeapYear();
};
Date::Date() : year(0), month(0), day(0) {}
int Date::getYear()
{
return this->year;
}
int Date::getMonth()
{
return this->month;
}
int Date::getDay()
{
return this->day;
}
void Date::print()
{
cout << "Today is " << setfill('0') << setw(2) << year << '/' << setfill('0') << setw(2) << month << '/' << setfill('0') << setw(2) << day << endl;
}
Date::Date(int year, int month, int day) : year(year), month(month), day(day) {}
void Date::setDate(int year, int month, int day)
{
this->year = year;
this->month = month;
this->day = day;
}
bool Date::isLeapYear()
{
return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}
void Date::addOneDay()
{
int daysInMonth[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
if (isLeapYear())
{
daysInMonth[2] = 29;
}
day++;
if (day > daysInMonth[month])
{
day = 1;
month++;
if (month > 12)
{
month = 1;
year++;
}
}
cout << "Tomorrow is " << setfill('0') << setw(2) << year << "/" << setfill('0') << setw(2) << month << "/" << setfill('0') << setw(2) << day << endl;
}
int main()
{
int t;
std::cin >> t;
while (t--)
{
int year, month, day;
cin >> year >> month >> day;
if (t % 2 == 0)
{
Date date(year, month, day);
date.print();
date.addOneDay();
}
else
{
Date date;
date.setDate(year, month, day);
date.print();
date.addOneDay();
}
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define quc ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
int gcd(int a, int b)
{
return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b)
{
return a / gcd(a, b) * b;
}
class CFraction
{
private:
int fz, fm;
public:
CFraction(int fz_val, int fm_val);
CFraction add(const CFraction& r);
CFraction sub(const CFraction& r);
CFraction mul(const CFraction& r);
CFraction div(const CFraction& r);
int getGCD(); // 求对象的分子和分母的最大公约数
void print();
};
int CFraction::getGCD()
{
return gcd(this->fm, this->fz);
}
CFraction::CFraction(int fz,int fm) : fz(fz),fm(fm) {}
CFraction CFraction::add(const CFraction& r)
{
int new_fz = fz * r.fm + fm * r.fz;
int new_fm = fm * r.fm;
int gcd_val = gcd(new_fz, new_fm);
return CFraction(new_fz / gcd_val, new_fm / gcd_val);
}
CFraction CFraction::sub(const CFraction& r)
{
int new_fz = fz * r.fm - fm * r.fz;
int new_fm = fm * r.fm;
int gcd_val = gcd(new_fz, new_fm);
if ((new_fm / gcd_val) < 0)
{
return CFraction(-(new_fz / gcd_val), -(new_fm / gcd_val));
}
return CFraction(new_fz / gcd_val, new_fm / gcd_val);
}
CFraction CFraction::mul(const CFraction& r)
{
int new_fz = fz * r.fz;
int new_fm = fm * r.fm;
int gcd_val = gcd(new_fz, new_fm);
return CFraction(new_fz / gcd_val, new_fm / gcd_val);
}
CFraction CFraction::div(const CFraction& r)
{
int new_fz = fz * r.fm;
int new_fm = fm * r.fz;
int gcd_val = gcd(new_fz, new_fm);
return CFraction(new_fz / gcd_val, new_fm / gcd_val);
}
void CFraction::print()
{
if (fm == 1)
{
cout << fz << '/' << 1 << endl;
}
else
{
cout << fz << "/" << fm << endl;
}
}
int main()
{
quc;
int t;
cin >> t;
while (t--)
{
string a;
string b;
cin >> a;
cin >> b;
int mid1, mid2, mid3, mid4;
sscanf(a.c_str(), "%d/%d", &mid1, &mid2);
sscanf(b.c_str(), "%d/%d", &mid3, &mid4);
CFraction CFa(mid1, mid2);
CFraction CFb(mid3, mid4);
CFa.add(CFb).print();
CFa.sub(CFb).print();
CFa.mul(CFb).print();
CFa.div(CFb).print();
cout << '\n';
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define quc ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
int gcd(int a, int b)
{
return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b)
{
return a / gcd(a, b) * b;
}
class Point
{
private:
double x, y;
public:
Point();
Point(double x, double y);
~Point();
double getX();
double getY();
void setXY(double x_value, double y_value);
void setX(double x_value);
void setY(double y_value);
double geiDisTo(Point &p);
};
Point::Point() : x(0), y(0) {}
Point::Point(double x, double y) : x(x), y(y) {}
Point::~Point() {} // 析构函数的实现
double Point::geiDisTo(Point& p)
{
return sqrt(pow(x - p.x, 2) + pow(y - p.y, 2));
}
double Point::getX()
{
return this->x;
}
double Point::getY()
{
return this->y;
}
void Point::setX(double x_value)
{
this->x = x_value;
}
void Point::setY(double y_value)
{
this->y = y_value;
}
void Point::setXY(double x_value, double y_value)
{
this->x = x_value;
this->y = y_value;
}
int main()
{
quc;
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vector<Point> points;
for (int i = 0; i < n; ++i)
{
double x, y;
cin >> x >> y;
points.push_back(Point(x, y));
}
int p1_index = 0, p2_index = 0;
double max_dist = 0;
Point* p1 = nullptr, * p2 = nullptr;
for (int i = 0; i < n; ++i)
{
for (int j = i + 1; j < n; ++j)
{
double dist = points[i].geiDisTo(points[j]);
if (dist > max_dist)
{
max_dist = dist;
Point* p1 = nullptr, * p2 = nullptr;
p1_index = i;
p2_index = j;
}
}
}
for (int i = 1; i <= n; i++)
{
cout << "Constructor." << '\n';
}
cout << "The longeset distance is " << fixed << setprecision(2) << max_dist << ",between p[" << p1_index << "] and p[" << p2_index << "]." << '\n';
for (int i = 1; i <= n; i++)
{
cout << "Distructor." << '\n';
}
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define quc ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
int gcd(int a, int b)
{
return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b)
{
return a / gcd(a, b) * b;
}
class cstack
{
private:
int* a;//栈的数组
int size;//栈中元素的数量
int top;//
public:
cstack();
cstack(int s);
int get(int index);
void push(int n);
int isempty();
int isfull();
int pop();
~cstack();
};
cstack::cstack()
{
top = 0;
size = 10;
cout << "Constructor." << '\n';
a = new int[10];//初始化动态数组
}
cstack::cstack(int n)
{
top = 0;
size = n;
cout << "Constructor." << '\n';
a = new int[n];//对栈内存赋值 数组有n个元素
}
int cstack::get(int index)
{
return a[index];
}
void cstack::push(int n)
{
a[top] = n;//存入数据
top++;
}
int cstack::isempty()
{
if (top == 0)
{
return 1;
}
else
{
return 0;
}
}
int cstack::isfull()
{
if (top == size)
{
return 1;
}
else
{
return 0;
}
}
int cstack::pop()
{
top--;
return a[top];
}
cstack::~cstack()
{
cout << "Destructor." << endl;
delete []a;//结束数组
}
int main()
{
int t, n, num, sign = 1;
cin >> t;
while (t--)
{
sign = 1;
cin >> n;
cstack st1(n);
for (int i = 0; i < n; i++)
{
cin >> num;
st1.push(num);
}
while (!st1.isempty())
{
if (sign)
{
cout << st1.pop();
sign = 0;
}
else
{
cout << ' ' << st1.pop();
}
}
cout << '\n';
}
return 0;
}