From efabe9d80cc0503eaae3da51ea37fff9ff05864b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=B5=B7?= <10402852@qq.com> Date: Thu, 22 Feb 2024 14:15:19 +0800 Subject: [PATCH] 'commit' --- .../LanQiaoBei/LanQiao15STEMA20231217/9.cpp | 26 +++++++++++++ .../LanQiao15STEMA20231217/试题.txt | 1 + TangDou/Test/TestA.cpp | 39 +++++++++---------- 3 files changed, 46 insertions(+), 20 deletions(-) create mode 100644 TangDou/LanQiaoBei/LanQiao15STEMA20231217/9.cpp create mode 100644 TangDou/LanQiaoBei/LanQiao15STEMA20231217/试题.txt diff --git a/TangDou/LanQiaoBei/LanQiao15STEMA20231217/9.cpp b/TangDou/LanQiaoBei/LanQiao15STEMA20231217/9.cpp new file mode 100644 index 0000000..0b2e4de --- /dev/null +++ b/TangDou/LanQiaoBei/LanQiao15STEMA20231217/9.cpp @@ -0,0 +1,26 @@ +#include +using namespace std; + +int main() { + string s; + cin >> s; + + int m; + cin >> m; + m--; + + while (m--) { + string t; + for (int i = 0; i < s.size(); i++) { + int c = 1; + while (i + 1 < s.size() && s[i + 1] == s[i]) { + c++; + i++; + } + t = t + to_string(c) + s[i]; + } + s = t; + } + cout << s << endl; + return 0; +} diff --git a/TangDou/LanQiaoBei/LanQiao15STEMA20231217/试题.txt b/TangDou/LanQiaoBei/LanQiao15STEMA20231217/试题.txt new file mode 100644 index 0000000..30c6074 --- /dev/null +++ b/TangDou/LanQiaoBei/LanQiao15STEMA20231217/试题.txt @@ -0,0 +1 @@ +https://tiku.scratchor.com/paper/view/z8k4y0xsf0ue8xlh diff --git a/TangDou/Test/TestA.cpp b/TangDou/Test/TestA.cpp index 1b6071b..9f73825 100644 --- a/TangDou/Test/TestA.cpp +++ b/TangDou/Test/TestA.cpp @@ -1,27 +1,26 @@ #include - using namespace std; -/** - 8 - 4 2 - 1 - 2 2 - 3 3 3 - 4 4 4 4 -*/ -int n, sum; int main() { - cin >> n; - for (int i = 1;; i++) { - n -= i; - if (n <= 0) { - // cout << i << " " << i + n << endl; - sum += i * (i + n); // 最后一行 - for (int j = 1; j < i; j++) sum += j * j; - cout << sum << endl; - break; + string s; + cin >> s; + + int m; + cin >> m; + m--; + + while (m--) { + string t; + for (int i = 0; i < s.size(); i++) { + int c = 1; + while (i + 1 < s.size() && s[i + 1] == s[i]) { + c++; + i++; + } + t = t + to_string(c) + s[i]; } + s = t; } + cout << s << endl; return 0; -} \ No newline at end of file +}