当前位置:网站首页>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;
}
边栏推荐
- 一位普通程序员一天工作清单
- 互聯網醫院HIS管理平臺源碼,在線問診,預約掛號 智慧醫院小程序源碼
- LeetCode13.罗马数字转整数(三种解法)
- 大变局!全国房价,跌破万元大关
- New library online | cnopendata complete data of Chinese insurance institution outlets
- 数仓任务里面 跑SQL任务的时候用的数据库账号是在哪里配置的
- Internet hospital his management platform source code, online consultation, appointment registration smart hospital applet source code
- TensorBoard快速入门(Pytorch使用TensorBoard)
- List of financial products in 2022
- QT adjust win screen brightness and sound size
猜你喜欢

kubernetes资源对象介绍及常用命令(四)
![[RT thread] NXP rt10xx device driver framework -- RTC construction and use](/img/19/91a9d84ba84f81ef125c33eb4007bc.png)
[RT thread] NXP rt10xx device driver framework -- RTC construction and use

Select 3 fcpx plug-ins. Come and see if you like them

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

Collection of the most beautiful graduation photos in the graduation season, collection of excellent graduation photos

How to train mask r-cnn model with your own data

SQL injection database operation foundation

C language modifies files by line

What is your income level in the country?

Play with fancy special effects. This AE super kit is for you
随机推荐
Unity notes unityxr simple to use
Financial management (Higher Vocational College) financial management online Assignment 1 in autumn 20
How to purchase Google colab members in China
Kubernetes resource object introduction and common commands (4)
One brush 147-force deduction hot question-4 find the median of two positive arrays (H)
Kotlin learning quick start (7) -- wonderful use of expansion
Notes on problems -- watching videos on edge will make the screen green
简单配置PostFix服务器
Electronic technology 20th autumn "Introduction to machine manufacturing" online assignment 3 [standard answer]
C language modifies files by line
Answer to the homework assessment of advanced English reading (II) of the course examination of Fuzhou Normal University in February 2022
How do large consumer enterprises make digital transformation?
One brush 144 force deduction hot question-1 sum of two numbers (E)
Squid service startup script
Enterprise custom form engine solution (XI) -- form rule engine 1
PR second time
Kubernetes resource object introduction and common commands (III)
[combinatorics] recursive equation (the non-homogeneous part is an exponential function and the bottom is the characteristic root | example of finding a special solution)
Where is the monitoring page of RDS database?
New library online | cnopendata China bird watching record data