Re: [問題] 複數&亂數的矩陣
#include <iostream>
#include <ctime>
#include <complex>
#include <vector>
#include <algorithm>
using namespace std;
typedef complex<double> complex_t;
typedef vector<complex<double>> complex_ct;
inline complex_t rand_complex(void) {
return complex_t(rand(), rand() / (RAND_MAX + 1.0));
}
int main(int argc, char* argv[]) {
srand((unsigned int)time(0));
complex_ct data;
generate_n(back_inserter(data), 15, rand_complex);
copy(data.begin(), data.end(), ostream_iterator<complex_t>(cout, "\n"));
system("pause");
return 0;
}
P幣 Get!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.195.88.23
推
06/13 14:09, , 1F
06/13 14:09, 1F
討論串 (同標題文章)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章