Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <vector>
- using namespace std;
- int matrica[4][4] = { {4, 6, 1, 0},
- {1, 2, 7, 6},
- {4, 6, 1, 3},
- {1, 4, 7, 6} };
- #define matrixSize 4
- //double matrica[3][3] = { {9,8,10},
- //{6, 5,4},
- //{3,2,1}};
- double f1(int w,int x, int y, vector<int> niz,int countXfirst) {
- double sum = 0;
- niz.push_back(x);
- if (w >= 2) {
- bool jumpSum = false;
- int countXNext = 0;
- for (int i = 0; i < matrixSize; i++) {
- jumpSum = false;
- for(int j=0; j<niz.size();j++){
- if(i == niz[j]){
- jumpSum = true;
- break;
- }
- }
- if(!jumpSum){
- if ((countXfirst+countXNext)%2) {
- sum -= matrica[y][x] * f1(w-1,i,y+1, niz,0);
- } else {
- sum += matrica[y][x] * f1(w-1,i,y+1, niz,0);
- }
- countXNext++;
- }
- }
- return sum;
- } else {
- return matrica[y][x];
- }
- return sum;
- }
- int main() {
- double det = 0;
- for (int i = 0; i < matrixSize; i++){
- vector<int> temp;
- det += f1(matrixSize,i,0,temp,i);
- }
- cout<<det<<endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment