timesparsematrix.cpp
来自「这是数据结构、算法与应用-C++语言描述的代码」· C++ 代码 · 共 30 行
CPP
30 行
// run time using class sparseMatrix as well as linkedMatrix
#include <iostream>
#include<time.h>
//#include "sparseMatrix.h"
#include "linkedMatrix.h"
using namespace std;
#pragma optimize("t", on)
int main()
{
linkedMatrix<int> a, b, c;
// sparseMatrix<int> a, b, c;
int m = 20000; // repetition factor
int n = 500; // matrix size
cin >> a;
cin >> b;
long startTime = clock();
for (int i = 1; i <= m; i++)
a.transpose(b);
double elapsedTime = ((double) (clock() - startTime)) / m;
cout << "Transpose time for n = " << n << " is "
<< elapsedTime << " milliseconds" << endl;
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?