Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_MATH_DEFINES
- #include <cmath>
- #include <iostream>
- #include <ctime>
- using namespace std;
- int main()
- {
- int M, N;
- double string_sum, row_product, duration;
- cin >> M;
- cin >> N;
- row_product = 1;
- double** Matrix = new double* [M];
- for (int i = 1; i <= M; i++)
- {
- Matrix[i - 1] = new double[N];
- for (int j = 1; j <= N; j++)
- {
- Matrix[i - 1][j - 1] = sqrt(i + j);
- //cout << Matrix[i - 1][j - 1] << "\t";
- }
- //cout << endl;
- }
- duration = clock();
- for (int i = 1; i <= M; i++)
- {
- string_sum = 0;
- for (int j = 1; j <= N; j++)
- {
- Matrix[i - 1][j - 1] = sqrt(i + j);
- string_sum += Matrix[i - 1][j - 1];
- }
- row_product *= string_sum;
- }
- duration = clock() - duration;
- cout << "Total product - " << row_product << endl;
- cout << "Time in ticks / secs - " << duration << " / " << duration / (double) CLOCKS_PER_SEC;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement