📄 list11-1.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 + -