Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- using namespace std;
- int slad(int a);
- int main()
- {
- int c;
- cout<<"obliczanie sladu macierzy"<<endl;
- cout<<"podaj rozmiar macierzy"<<endl;
- int a;
- cin>>a;
- c=slad(a);
- cout<<"Slad macierzy = "<<c;
- getch();
- }
- int slad(int a)
- {
- int wynik=0;
- int **tab;
- tab=new int*[a];
- for(int i=0;i<a;i++)
- {
- tab[i]=new int[a];
- }
- cout<<"wypelnij macierz liczbami:"<<endl;
- for(int i=0;i<a;i++)
- {
- for(int j=0;j<a;j++)
- {
- cin>>tab[i][j];
- }
- }
- cout<<"wypelniona macierz"<<endl;
- for(int i=0;i<a;i++)
- {
- for(int j=0;j<a;j++)
- {
- cout<<tab[i][j]<<" ";
- }
- cout<<endl;
- }
- for(int i=0;i<a;i++)
- {
- for(int j=0;j<a;j++)
- {
- if(i==j)
- {
- wynik+=tab[i][j];
- }
- }
- }
- return wynik;
- }
Add Comment
Please, Sign In to add comment