⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 list11-1.cpp

📁 这是关于VC++中的STL容器的资料,包括了STL容器各个类之间关系以及类的说明
💻 CPP
字号:

// Listing 11.1
// This program uses numeric_limits::epsilon(), and
// numeric_limits::max() To build a test case vector.

#include <stdlib.h>
#include <iostream>
#include <limits>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <iomanip>

using namespace std;

void main(void)
{

    int N;
    vector<float> TestSet;
    vector<float>::iterator I;
    string R;
    numeric_limits<float> Real;
    stringstream Stream;
    srand(Real.epsilon());
    TestSet.push_back(Real.max());
    TestSet.push_back(Real.epsilon());
    for(N = 0;N < 40;N++)
    {

       TestSet.push_back(rand() * 0.10);
    }
    random_shuffle(TestSet.begin(),TestSet.end());
    I = TestSet.begin();
    cout.precision(10);
    cout.setf(ios::showpoint | ios::fixed);
    Stream << setiosflags(ios::showpoint | ios::fixed) <<  Real.max() << ends;
    Stream >> R;
    while(I != TestSet.end())
    {
       cout << setw(R.length()) << *I << endl;
       I++;
    }



}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -