Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <time.h>
- #include <cstdlib>
- using namespace std;
- int dodawanie(int a[10][10], int b[10][10], int c[10][10])
- {
- for (int i = 0; i<10; i++)
- {
- for (int k = 0; k< 10; k++)
- {
- c[i][k] = a[i][k] + b[i][k];
- }
- }
- return 0;
- }
- void wyswietl(int tab[10][10])
- {
- for (int i = 0; i<10; i++)
- {
- for (int k = 0; k<10; k++)
- {
- cout << tab[i][k] << " ";
- }
- cout << endl;
- }
- }
- void transpozycja(int tab[10][10])
- {
- for (int i = 0; i<10; i++)
- {
- for (int k = 0; k<10; k++)
- {
- cout << tab[k][i] << " ";
- }
- cout << endl;
- }
- }
- void diagonal(int tab[10][10])
- {
- int w = 0;
- for (int i = 0; i < 10; i++)
- {
- for (int k = 0; k < 10; k++)
- {
- if (w == i && w == k)
- {
- cout << tab[i][k] << " ";
- }
- else
- {
- tab[i][k] = 0;
- cout << tab[i][k] << " ";
- }
- }
- cout << endl;
- w++;
- }
- }
- int main()
- {
- int poczatek, koniec;
- int tab[10][10], tab2[10][10], tab3[10][10];
- srand(time(NULL));
- cout << "Jakub Gąsior" << endl;
- cout << "Podaj początek przedziału" << endl;
- cin >> poczatek;
- cout << "Podaj koniec przedzialu:" << endl;
- cin >> koniec;
- cout << "Wypełnianie tablicy" << endl;
- for (int i = 0; i<10; i++)
- {
- for (int k = 0; k<10; k++)
- {
- tab[i][k] = (rand() % (koniec + 1 - poczatek) + poczatek);
- }
- }
- for (int i = 0; i<10; i++)
- {
- for (int k = 0; k<10; k++)
- {
- tab2[i][k] = (rand() % (koniec + 1 - poczatek) + poczatek);
- }
- }
- cout << "Tablica 1:" << endl;
- wyswietl(tab);
- cout << "Tablica 2:" << endl;
- wyswietl(tab2);
- cout << "Dodawanie: " << endl;
- dodawanie(tab, tab2, tab3);
- wyswietl(tab3);
- cout << "Transpozycja:" << endl;
- transpozycja(tab3);
- cout << "Tablica diagonalna:" << endl;
- diagonal(tab3);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement