c++primer 练习9.28

2021-01-19 23:14

阅读:407

标签:list   prime   div   argv   prim   color   lag   void   ++   

 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 }

 

c++primer 练习9.28

标签:list   prime   div   argv   prim   color   lag   void   ++   

原文地址:https://www.cnblogs.com/otakus/p/12905908.html


评论


亲,登录后才可以留言!