Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int *q, *p, *r, k,y,l,c,total, matrice[100][100];
- cout << "Introduceti liniile si coloanele matricelor: ";
- cin >> l >> c;
- total = l * c;
- q = new int(total);
- p = new int(total);
- r = new int(total);
- cout << "Introduceti elementele matricii 1: " << endl;
- for (int i = 0; i < total; i++) {
- cin >> q[i];
- }
- cout << "Introduceti elementele matricii 2: " << endl;
- for (int i = 0; i < l; i++) {
- for (int j = 0; j < c; j++) {
- cin >> matrice[i][j];
- }
- }
- k = 0;
- for (int i = 0; i < l; i++) {
- for (int j = 0; j < c; j++) {
- p[k] = matrice[j][i];
- k++;
- }
- }
- k = 0;
- y = 0;
- for (int i = 0; i < total; i++) {
- if (i < sqrt(total)) {
- k = 0;
- }
- else {
- k = 2;
- }
- if (i%2==0) {
- y = 0;
- } else {
- y = 2;
- }
- r[i] = q[k] * p[y];
- }
- k = 0;
- y = 0;
- for (int i = 0; i < total; i++) {
- if (i < sqrt(total)) {
- k = 1;
- } else {
- k = 3;
- }
- if (i%2==0) {
- y = 1;
- } else {
- y = 3;
- }
- r[i] += q[k] * p[y];
- }
- for (int i = 0; i < total; i++)
- {
- cout << r[i] << " ";
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement