diff --git a/TangDou/LanQiaoBei/LanQiao15STEMA20231217/10.cpp b/TangDou/LanQiaoBei/LanQiao15STEMA20231217/10.cpp index df981a0..544cb68 100644 --- a/TangDou/LanQiaoBei/LanQiao15STEMA20231217/10.cpp +++ b/TangDou/LanQiaoBei/LanQiao15STEMA20231217/10.cpp @@ -8,7 +8,6 @@ string kill(string s) { p = i; break; } - string res; for (int i = 0; i < s.size(); i++) if (i != p) res += s[i]; @@ -17,9 +16,7 @@ string kill(string s) { int main() { string s; - cin >> s; - - cin >> k; + cin >> s >> k; for (int i = 1; i <= k; i++) s = kill(s); cout << s << endl; return 0; diff --git a/TangDou/LanQiaoBei/LanQiao15STEMA20231217/G.cpp/G.cpp b/TangDou/LanQiaoBei/LanQiao15STEMA20231217/G.cpp/G.cpp new file mode 100644 index 0000000..4703bd8 --- /dev/null +++ b/TangDou/LanQiaoBei/LanQiao15STEMA20231217/G.cpp/G.cpp @@ -0,0 +1,19 @@ +#include +using namespace std; +string s; +int n; +int main() { + cin >> s >> n; + n--; + while (n--) { + string t; + for (int i = 0; i < s.size(); i++) { + int cnt = 1; + while (i + 1 < s.size() && s[i] == s[i + 1]) cnt++, i++; + t += to_string(cnt) + s[i]; + } + s = t; + } + cout << s << endl; + return 0; +} \ No newline at end of file diff --git a/TangDou/LanQiaoBei/LanQiao15STEMA20231217/G2.cpp b/TangDou/LanQiaoBei/LanQiao15STEMA20231217/G2.cpp new file mode 100644 index 0000000..8751b9a --- /dev/null +++ b/TangDou/LanQiaoBei/LanQiao15STEMA20231217/G2.cpp @@ -0,0 +1,19 @@ +#include +using namespace std; +string s; +int n; +int main() { + cin >> s >> n; + n--; + while(n--){ + string t; + for (int i = 0; i < s.size(); i++){ + int cnt = 1; + while (i + 1 < s.size() && s[i + 1]==s[i]) cnt++, i++; + t += to_string(cnt) + s[i]; + } + s = t; + } + cout << s << endl; + return 0; +} \ No newline at end of file