?? chapter6-13.cpp
字號(hào):
//文件名:CHAPTER6-13.cpp
#pragma warning(disable:4786)
#include <iostream.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
class IsAToothbrush
{
public:
IsAToothbrush(string& InToothbrushCode) : ToothbrushCode(InToothbrushCode) {}
bool operator() (string& SalesRecord)
{ return SalesRecord.substr(0,4)==ToothbrushCode; }
private:
string 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");
string VariableToothbrushCode("0003");
int NumberOfToothbrushes(0);
NumberOfToothbrushes = count_if (SalesRecords.begin(), SalesRecords.end(),
IsAToothbrush(VariableToothbrushCode));
cout << "There were " << NumberOfToothbrushes << " toothbrushes matching code "<< "0003" << " sold" << endl;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -