head File
#include <vector>
#include <QDebug>
#include<qmath.h>
#include <QTime>
using namespace std;
class Vector_test
{
public:
Vector_test();
double rand();
};
Source File
Vector_test::Vector_test()
{
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
vector<double> arrayTest(10);
qDebug() << arrayTest;
for (int i = 0; i < 10; ++i) {
arrayTest[i] = rand();
}
qDebug() << arrayTest;
}
double Vector_test::rand()
{
return (qrand()%10)/10.0+(qrand()%10)/100.0+(qrand()%10)/1000.0;
}
result
std::vector(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
std::vector(0.163, 0.111, 0.24, 0.007, 0.046, 0.734, 0.936, 0.885, 0.76, 0.425)