当前位置:网站首页>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;
}
边栏推荐
- Select 3 fcpx plug-ins. Come and see if you like them
- What is your income level in the country?
- Play with fancy special effects. This AE super kit is for you
- Collection of the most beautiful graduation photos in the graduation season, collection of excellent graduation photos
- [combinatorics] recursive equation (the problem of solving recursive equation with multiple roots | the problem is raised)
- Svn full backup svnadmin hotcopy
- 在iptables防火墙下开启vsftpd的端口
- Examination questions for the assignment of selected readings of British and American Literature in the course examination of Fujian Normal University in February 2022
- 新库上线 | CnOpenData中国保险机构网点全集数据
- HP 阵列卡排障一例
猜你喜欢

【RT-Thread】nxp rt10xx 设备驱动框架之--Audio搭建和使用

鸿蒙第四次培训

Leetcode Valentine's Day Special - looking for a single dog

Internet hospital his management platform source code, online consultation, appointment registration smart hospital applet source code

互联网医院HIS管理平台源码,在线问诊,预约挂号 智慧医院小程序源码

What is your income level in the country?

问题随记 —— 在 edge 上看视频会绿屏

Automata and automatic line of non-standard design

大变局!全国房价,跌破万元大关

Introduction to SolidWorks gear design software tool geartrax
随机推荐
Kotlin学习快速入门(7)——扩展的妙用
Luogu: p1155 [noip2008 improvement group] double stack sorting (bipartite graph, simulation)
新库上线 | CnOpenData中国观鸟记录数据
How SVN views modified file records
Where is the monitoring page of RDS database?
人生还在迷茫?也许这些订阅号里有你需要的答案!
Y is always discrete and can't understand, how to solve it? Answer: read it several times
Electronic Science and technology 20th autumn "Microcomputer Principle and application" online assignment 2 [standard answer]
Comparison of kotlin collaboration + retro build network request schemes
[combinatorics] recursive equation (example of solving recursive equation without multiple roots | complete process of solving recursive equation without multiple roots)
Qt调节Win屏幕亮度和声音大小
Golang单元测试、Mock测试以及基准测试
免费数据 | 新库上线 | CnOpenData中国保险中介机构网点全集数据
c# .net 工具生态
Electronic technology 20th autumn "Introduction to machine manufacturing" online assignment 3 [standard answer]
vs code 插件 koroFileHeader
PS screen printing brush 131, many illustrators have followed suit
The largest matrix (H) in a brush 143 monotone stack 84 histogram
[combinatorics] recursive equation (general solution structure of recursive equation with multiple roots | linear independent solution | general solution with multiple roots | solution example of recu
STM32H7 HAL库SPI DMA发送一直处于busy的解决办法