当前位置:网站首页>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;
}
边栏推荐
- Simple use of unity pen XR grab
- kubernetes资源对象介绍及常用命令(五)-(NFS&PV&PVC)
- Qt调节Win屏幕亮度和声音大小
- RedHat 6.2 配置 Zabbix
- [combinatorics] recursive equation (solution of linear non-homogeneous recursive equation with constant coefficients | standard form and general solution of recursive equation | proof of general solut
- 【RT-Thread】nxp rt10xx 设备驱动框架之--hwtimer搭建和使用
- Play with fancy special effects. This AE super kit is for you
- [combinatorics] recursive equation (case where the non-homogeneous part is exponential | example where the non-homogeneous part is exponential)
- 基于主机的入侵系统IDS
- Open vsftpd port under iptables firewall
猜你喜欢
Introduction to SolidWorks gear design software tool geartrax
C language modifies files by line
Hongmeng fourth training
Play with fancy special effects. This AE super kit is for you
[combinatorics] recursive equation (summary of the solution process of recursive equation | homogeneous | double root | non-homogeneous | characteristic root is 1 | exponential form | the bottom is th
How to purchase Google colab members in China
kubernetes资源对象介绍及常用命令(三)
How do large consumer enterprises make digital transformation?
SWM32系列教程4-端口映射及串口应用
Type conversion, variable
随机推荐
Javescript variable declaration -- VaR, let, const
在iptables防火墙下开启vsftpd的端口
自动渗透测试工具核心功能简述
Apache服务挂起Asynchronous AcceptEx failed.
Internet Hospital his Management Platform source, online Inquiry, appointment Registration Smart Hospital Small program source
Golang unit test, mock test and benchmark test
Examination questions for the assignment of selected readings of British and American Literature in the course examination of Fujian Normal University in February 2022
Luogu: p2685 [tjoi2012] Bridge
【RT-Thread】nxp rt10xx 设备驱动框架之--hwtimer搭建和使用
[combinatorics] recursive equation (the non-homogeneous part is an exponential function and the bottom is the characteristic root | example of finding a special solution)
人生还在迷茫?也许这些订阅号里有你需要的答案!
鸿蒙第三次培训
鸿蒙第四次培训
Kubernetes resource object introduction and common commands (4)
[RT thread] NXP rt10xx device driver framework -- Audio construction and use
Electronic technology 20th autumn "Introduction to machine manufacturing" online assignment 3 [standard answer]
[combinatorics] recursive equation (example of solving recursive equation without multiple roots | complete process of solving recursive equation without multiple roots)
Online assignment 3 of mobile Internet technology in the 20th autumn of electronic technology [standard answer]
New library online | cnopendata complete data of Chinese insurance institution outlets
1146_ SiCp learning notes_ exponentiation