removegroup.cpp
来自「Thinking in C++ 2nd edition source code 」· C++ 代码 · 共 31 行
CPP
31 行
//: C26:RemoveGroup.cpp
// From Thinking in C++, 2nd Edition
// at http://www.BruceEckel.com
// (c) Bruce Eckel 1999
// Copyright notice in Copyright.txt
// Remove a group of names from a list
#include <list>
#include "../require.h"
#include "readLower.h"
using namespace std;
typedef list<string> Container;
int main(int argc, char **argv) {
requireArgs(argc, 4);
Container names, removals;
readLower(argv[1], names);
readLower(argv[2], removals);
long original = names.size();
Container::iterator rmit = removals.begin();
while(rmit != removals.end())
names.remove(*rmit++); // Removes all matches
ofstream out(argv[3]);
assure(out, argv[3]);
copy(names.begin(), names.end(),
ostream_iterator<string>(out,"\n"));
long removed = original - names.size();
cout << "On removal list: " << removals.size()
<< endl << "Removed: " << removed << endl;
} ///:~
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?