Results 1 to 1 of 1
Thread: ?
Hybrid View
-
31st December 2013 00:20 #1Registered User
Join Date: Aug:2012
Location:
Posts: 297
?
, , - ,
1 2
3 4
10, 1.4 + 2.3 = 10 ,
1 2 3
4 5 6
7 8 9
450, 1.5.9 + 1.6.8 + 2.4.9 + 2.6.7 + 3.4.8 + 3.5.7 = 450.
:
: col[j] , ( , ). tmp -Code:#include <iostream> using namespace std; void det(int arr[][20] , bool col[20] , int n , int &sum , int i , int counter, int tmp ) { if(counter == n) { sum+=tmp; return; } for(int j = 0 ; j<= n-1 ; j++) if(col[j]) { col[j] = 0 ; det(arr, col , n , sum , i+1 ,counter + 1,tmp*arr[i][j]); col[j] = 1; } } int main() { int arr[20][20]; cout << "Enter n : "; int n ; cin >> n; cout << "Enter the matrix: " << endl ; for(int i = 0 ; i <= n-1 ; i ++) for(int j = 0 ; j <= n-1 ; j++) cin >> arr[i][j]; bool col[20]; for(int i = 0 ; i <= n-1 ; i ++ ) col[i] = 1; int sum = 0; det(arr , col , n , sum , 0 , 0 , 1); cout << sum << endl; cin.sync(); cin.get(); return 0 ; }
1 2
3 4 1.4 , 2.3 . , " " sum. Sum .Counter " " . i ( , , ..). counter i ? .
( , void ... ) , counter ( i) . , ( ). , / /.
, . , , . , C++ , , .
, .




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in