当前位置:网站首页>Write a program to process a list container of string type. Find a special value in the container 9.27: and delete it if found. Rewrite the above procedure with deque container.
Write a program to process a list container of string type. Find a special value in the container 9.27: and delete it if found. Rewrite the above procedure with deque container.
2022-07-03 17:29:00 【qq_ fifty-eight million seven hundred and thirty-six thousand t】
//list Containers
#include<iostream>
#include<list>
using namespace std;
int main(void)
{
string str[] = { "hello","world","!" }, str1;
std::list<string> strs;
for (size_t i = 0; i != 3; i++)
strs.push_back(str[i]);
cout << " Please enter the value to be deleted " << endl<< "hello, world, !"<<endl;
cin >> str1;
for (std::list<string>::iterator it = strs.begin(); it != strs.end();)
{
if (str1 == *it)
strs.erase(it++);
else
it++;
}
cout << " The rest is worth " << endl;
for (std::list<string>::iterator it = strs.begin(); it != strs.end(); it++)
cout << *it;
return 0;
}
//deque Containers
#include<deque>
#include<iostream>
using namespace std;
int main(void)
{
string str[] = { "hello","world","!" }, str1;
std::deque<string> strs;
for (size_t i = 0; i != 3; i++)
strs.push_back(str[i]);
cout << " Please enter the value to be deleted " << endl << "hello, world, !" << endl;
cin >> str1;
for (std::deque<string>::iterator it = strs.begin(); it != strs.end(); it++)
{
if (str1 == *it)
{
it=strs.erase(it);// Return to the next it Coordinates are it++ Assign a value to it;
}
}
cout << " The rest is worth " << endl;
for (std::deque<string>::iterator it = strs.begin(); it != strs.end(); it++)
cout << *it;
return 0;
}
边栏推荐
- Vs2013 has blocked the installer, and ie10 needs to be installed
- Unity notes unityxr simple to use
- Collection of the most beautiful graduation photos in the graduation season, collection of excellent graduation photos
- 1147_ Makefile learning_ Target files and dependent files in makefile
- 新库上线 | CnOpenData中国观鸟记录数据
- Loop through JSON object list
- Is AI too slow to design pictures and draw illustrations? 3 sets of practical brushes to save you
- How to read the source code [debug and observe the source code]
- Simple use of unity pen XR grab
- 互联网医院HIS管理平台源码,在线问诊,预约挂号 智慧医院小程序源码
猜你喜欢
Hongmeng third training
[UE4] brush Arctic pack high quality Arctic terrain pack
kubernetes资源对象介绍及常用命令(四)
Luogu: p2685 [tjoi2012] Bridge
Unity notes unityxr simple to use
Cross border e-commerce: advantages of foreign trade enterprises in overseas social media marketing
Swm32 series Tutorial 4 port mapping and serial port application
鸿蒙第四次培训
Leetcode Valentine's Day Special - looking for a single dog
Notes on problems -- watching videos on edge will make the screen green
随机推荐
Internet hospital his management platform source code, online consultation, appointment registration smart hospital applet source code
First day of rhcsa study
One brush 149 force deduction hot question-10 regular expression matching (H)
Kotlin学习快速入门(7)——扩展的妙用
vs code 插件 koroFileHeader
Wechat applet for the first time
TensorBoard快速入门(Pytorch使用TensorBoard)
Detailed explanation of common network attacks
Online assignment 3 of mobile Internet technology in the 20th autumn of electronic technology [standard answer]
Simple use of unity pen XR grab
C language string practice
The largest matrix (H) in a brush 143 monotone stack 84 histogram
Loop through JSON object list
Life is still confused? Maybe these subscription numbers have the answers you need!
Examination questions for the assignment of selected readings of British and American Literature in the course examination of Fujian Normal University in February 2022
Solution to long waiting time of SSH connection to remote host
The difference between get and post
互聯網醫院HIS管理平臺源碼,在線問診,預約掛號 智慧醫院小程序源碼
Vs code plug-in korofileheader
Kotlin learning quick start (7) -- wonderful use of expansion