Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <iostream>
- using namespace std;
- class Macierz {
- public:
- double **mac;
- int n, m;
- Macierz(int n, int m) {
- this->n = n;
- this->m = m;
- mac = new double*[n];
- for (int i = 0; i<n; i++) {
- mac[i] = new double[m];
- }
- }
- void add_mac() {
- for (int i = 0; i<n; i++) {
- for (int j = 0; j<m; j++) {
- while (!(cin >> mac[i][j])) {
- cout << "Podano nieprawidlowy znak! Sprobuj jeszcze raz" << endl << endl;
- cin.clear();
- cin.sync();
- }
- }
- }
- system("cls");
- }
- void show_mac() {
- for (int i = 0; i<n; i++) {
- for (int j = 0; j<m; j++) {
- cout << "\t" << mac[i][j];
- }
- cout << endl;
- }
- }
- void suma(Macierz & maciorka) {
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < m; j++)
- mac[i][j] += maciorka.mac[i][j];
- }
- }
- double roznica() {
- }
- double iloczyn() {
- }
- };
- int main(int argc, char** argv) {
- Macierz m1(3, 3);
- Macierz m2(3, 3);
- Macierz m3(3, 3);
- cout << "Wprowadz dane 1 tablicy: " << endl;
- m1.add_mac();
- cout << "Wprowadz dane 2 tablicy: " << endl;
- m2.add_mac();
- cout << "Twoja pierwsza macierz: " << endl << endl;
- m1.show_mac();
- cout << endl << "Twoja druga macierz: " << endl << endl;
- m2.show_mac();
- cout << endl;
- cout << endl;
- m2.suma(m1);
- m2.show_mac();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement