Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main()
- {
- srand( time( NULL ) );
- double det;
- int n,sam;
- bool wh= true;
- cout << "Jeoli chcesz samemu podawaa liczby do macierzy wybierz 0, jeoli chcesz ?eby liczby pojawi3y sie losowo wybierz 1" << endl;
- cin>>sam;
- cout << "Podaj poziom tablicy (liczbe wierszy oraz kolumn)" << endl;
- cin >>n;
- double tab_A[n][n];
- det=tab_A[0][0];
- if(sam==1){
- for(int i = 0 ; i<n ; i++)
- {
- for(int j = 0 ; j<n ; j++)
- {
- tab_A[i][j]=rand()%10;
- cout<<tab_A[i][j]<< " " ;
- }
- cout<<"\n\n";
- }
- }
- if(sam==0){
- for(int i = 0 ; i<n ; i++)
- {
- for(int j = 0 ; j<n ; j++)
- {
- cout<<"Podaj liczbe która bedzie w wierszu "<< i<< " Oraz kolumnie "<<j<< endl; ;
- cin>>tab_A[i][j];
- }
- cout<<"\n\n";
- }}
- det=tab_A[0][0];
- for(int z=0; z<n-1; z++)
- {
- for(int i=z+1; i<n; i++)
- {
- for(int j=z+1;j<n;j++)
- {
- tab_A[i][j]=tab_A[i][j]-(tab_A[i][z]/tab_A[z][z])*tab_A[z][j];
- }
- }
- det=det*tab_A[z+1][z+1];
- }
- cout << "Wyznacznik wynosi " << det << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement