Untitled
unknown
plain_text
2 years ago
851 B
3
Indexable
#include <iostream> #include <stdlib.h> #include <time.h> using namespace std; int main() { int* arrayA, * arrayB, * arrayC, i, j, k, sum = 0; arrayA = new int[10000]; arrayB = new int[10000]; arrayC = new int[10000]; int m_width = 100; clock_t startTime = clock(); for (i = 0; i < 10000; ++i) { arrayA[i] = rand() % 100; arrayB[i] = rand() % 100; } for (i = 0; i < m_width; ++i) { for (j = 0; j < m_width; ++j) { sum = 0; for (k = 0; k < m_width; ++k) { sum += arrayA[i * m_width + k] * arrayB[k * m_width + j]; } arrayC[i * m_width + j] = sum; cout<<arrayC[i]<<" "; } cout<<endl; } clock_t stopTime = clock(); float secsElapsed = (float)(stopTime - startTime)/CLOCKS_PER_SEC; cout <<endl << "Time Taken:" << secsElapsed; return 0; }
Editor is loading...