我正在尝试编写字符串列表.用户可以添加到列表或从列表中删除,以及显示当前列表.
显示列表和添加到列表工作正常,但我无法弄清楚如何通过遍历列表来查找匹配来删除用户的字符串.
我如何更改我的代码来解决这个问题? 看看是否(答案== 3)
// InClassAssignment-FavouriteGameList.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <string>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cctype>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
vector <string> gameList;
int answer = 0;
bool cont = true;
int size = 0;
vector<string>::iterator iter;
string addToList;
string removeFromList;
cout << "\tGame List" << endl;
while (cont)
{
cout << "--------------------------------------------" << endl;
cout << "\nWhat …Run Code Online (Sandbox Code Playgroud)