#include <iostream>
#include <iomanip>
using std::cin;
using std::cout;
using std::endl;
int main()
{
int a = 21;
cout << std::hex << a << endl;
cout.width(5);
cout.fill('*');
cout << std::oct << a << endl;
cout <<std::setfill(' ')<<std::setw(1)<< std::dec << a << endl;
cout.precision(2);
cout << 15.6 << endl;
cout <<std::setprecision(6)<< std::fixed <<15.6<< endl;
cout << std::scientific << 15.6 << endl;
cout.unsetf(std::ios_base::floatfield);
cout << 15.60 << endl << std::showpoint << 15.60 << endl;
return 0;
}

在#include <iostream>
#include <iomanip>
#include <vector>
#include <ctime>
#include <algorithm>
using std::cin;
using std::cout;
using std::endl;
class f_mod
{
private:
int mod;
public:
f_mod() { mod = 5; }
f_mod(const int& m) :mod(m) {}
bool operator()(const int& n) { return n % mod == 0; }
}f;
bool f3(const int& x) { return x % 3 == 0; }
int main()
{
std::vector<int>numbers(10);
std::srand(std::time(0));
std::generate(numbers.begin(), numbers.end(), std::rand);
for (auto p = numbers.begin(); p != numbers.end(); p++)
cout << *p << endl;
int count3 = std::count_if(numbers.begin(), numbers.end(), f3);
int count5 = std::count_if(numbers.begin(), numbers.end(), f_mod(5));
int count7 = std::count_if(numbers.begin(), numbers.end(), [](const int&x) { return x % 7 == 0; });
auto mod7 = [](const int& x) {return x % 7 == 0; };
int count7_ = std::count_if(numbers.begin(), numbers.end(), mod7);
bool result = mod7(15);
int count9 = 0;
std::for_each(numbers.begin(), numbers.end(), [&count9](const int& x) {count9 += x % 9 == 0; });
int count11 = 0, count13 = 0, count15 = 0;
std::for_each(numbers.begin(), numbers.end(), [&](const int& x) {count11 += x % 11 == 0; count13 += x % 13 == 0; count15 += x % 15 == 0; });
cout << count3 << endl << count5 << endl << count7 << endl
<< count7_<< endl << count9 << endl << count11 << endl
<< count13 << endl << count15<<endl;
