摘要: Original as below via recursion and will call the method itself for many times which is inefficient int Util::factorial54(int i) { if(i==0 ||i==1) { r 阅读全文
posted @ 2022-03-19 20:38 FredGrit 阅读(16) 评论(0) 推荐(0) 编辑
摘要: void Util::fib53(int *arr, int num, int &result) { arr[0]=0; arr[1]=1; for(int i=2;i<=num;i++) { arr[i]=arr[i-2]+arr[i-1]; } for(int i=0;i<=num;i++) { 阅读全文
posted @ 2022-03-19 20:21 FredGrit 阅读(18) 评论(0) 推荐(0) 编辑
摘要: void Util::getArray23(int *arr, int len) { srand(time(NULL)); for (int i = 0; i < len; i++) { arr[i] = rand(); } } void Util::printArray24(int *arr, i 阅读全文
posted @ 2022-03-19 19:14 FredGrit 阅读(31) 评论(0) 推荐(0) 编辑
摘要: void Util::logFile21(string fileName) { fstream wFile(fileName, ios::app); if (!wFile.is_open()) { cout << "Create or open " << fileName << " failed!" 阅读全文
posted @ 2022-03-19 18:04 FredGrit 阅读(34) 评论(0) 推荐(0) 编辑
摘要: void Util::getStructVector(vector<BookStruct> &vec, int len) { for (int i = 0; i < len; i++) { BookStruct bs; bs.BookIndex = i; bs.BookId = (unsigned 阅读全文
posted @ 2022-03-19 17:37 FredGrit 阅读(34) 评论(0) 推荐(0) 编辑
摘要: void Util::getArray23(int *arr, int len) { srand(time(NULL)); for (int i = 0; i < len; i++) { arr[i] = rand(); } } void Util::printArray24(int *arr, i 阅读全文
posted @ 2022-03-19 17:05 FredGrit 阅读(17) 评论(0) 推荐(0) 编辑