📄 chapter6-12.cpp
字号:
//文件名:CHAPTER6-12.cpp
#pragma warning(disable:4786)
#include <iostream.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
const string ToothbrushCode("0003");
class IsAToothbrush
{public:
bool operator() ( string& SalesRecord ) {return SalesRecord.substr(0,4)==ToothbrushCode;}
};
void main (void)
{
vector<string> SalesRecords;
SalesRecords.push_back("0001 Soap");
SalesRecords.push_back("0002 Shampoo");
SalesRecords.push_back("0003 Toothbrush");
SalesRecords.push_back("0004 Toothpaste");
SalesRecords.push_back("0003 Toothbrush");
int NumberOfToothbrushes(0);
NumberOfToothbrushes = count_if (SalesRecords.begin(), SalesRecords.end(),IsAToothbrush());
cout << "There were " << NumberOfToothbrushes << " toothbrushes sold" << endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -