Re: [問題] 複數&亂數的矩陣

看板C_and_CPP (C/C++)作者 (克里斯)時間16年前 (2009/06/13 14:02), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/4 (看更多)
#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
看不懂T_T天阿...
06/13 14:09, 1F
文章代碼(AID): #1ACq3rwL (C_and_CPP)
文章代碼(AID): #1ACq3rwL (C_and_CPP)