c++primer 练习9.28
2021-01-19 23:14
标签:list prime div argv prim color lag void ++ c++primer 练习9.28 标签:list prime div argv prim color lag void ++ 原文地址:https://www.cnblogs.com/otakus/p/12905908.html 1 void func(forward_liststring>& flst, const string& s1, const string& s2) {
2 auto bb = flst.before_begin();
3 bool flag = false;
4 for (auto j : flst) {
5 if (j == s1)
6 { flag = true; break; }
7 }
8 for (auto i = flst.begin(); i != flst.end(); ++i)
9 {
10 if (*i == s1)
11 {
12 bb = i;
13 flst.insert_after(bb, s2);
14 }
15 else
16 bb = i;
17 }
18 if (flag == false) { flst.insert_after(bb, s2); }
19 }
20 int main(int argc, char* argv[])
21 {
22 forward_liststring>f{ "1","2","3","4" };
23 func(f, "5", "6");
24 for (auto i : f)
25 cout endl;
26 }
下一篇:Python 进度条