From ef7b0af039c96ae8cfe8c57233df3ed7b0d7b014 Mon Sep 17 00:00:00 2001 From: flykhan Date: Thu, 15 Jun 2023 16:43:42 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=AE=E7=9B=98=E8=8E=B7=E5=8F=96=E8=BE=93?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day4/d10.cpp | 15 +++++++++++++++ day4/d8.cpp | 13 +++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 day4/d10.cpp create mode 100644 day4/d8.cpp diff --git a/day4/d10.cpp b/day4/d10.cpp new file mode 100644 index 0000000..17d3a22 --- /dev/null +++ b/day4/d10.cpp @@ -0,0 +1,15 @@ +#include + +using namespace std; + +int main() +{ + char c = 'a'; // 1B + int m = 2; // 4B + // 小字节转大字节, 会自动转换 + m += c; // 先将c转换为int,再相加 + cout << "m = " << m << endl; + // 大字节转小字节,会丢失精度,需要强制类型转换 + cout << "m to char is " << (char)m << endl; + return 0; +} \ No newline at end of file diff --git a/day4/d8.cpp b/day4/d8.cpp new file mode 100644 index 0000000..8fc5fd9 --- /dev/null +++ b/day4/d8.cpp @@ -0,0 +1,13 @@ +#include + +using namespace std; + +int main() +{ + int x1, y1, x2, y2; + cout << "请输入两个点坐标, 格式如 x1 y1 x2 y2" << endl; + cin >> x1 >> y1 >> x2 >> y2; + cout << "P1(" << x1 << "," << y1 << ")" + << " P2(" << x2 << "," << y2 << ")" << endl; + return 0; +} \ No newline at end of file