Advertisement
Sabab

mat

Feb 12th, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int Maximum(int a[100]){
  5. int temp;
  6. for(int i=0;i<3;i++){
  7.     for(int j=i+1;j<4;j++){
  8.         if(a[i]>a[j]){
  9.             temp=a[i];
  10.             a[i]=a[j];
  11.             a[j]=temp;
  12.         }
  13.  
  14.     }
  15.  
  16.  
  17.  
  18. }
  19.  
  20.  
  21.  
  22. return a[3];
  23. }
  24.  
  25. int main(){
  26.  
  27. int testCase;
  28.  
  29. cin>>testCase;
  30.  
  31. for(int t=0;t<testCase;t++){
  32.  
  33.  
  34. int n;
  35. cin>>n;
  36. int row=2*n;
  37. int col=2*n;
  38. int mat[500][500];
  39. int sum=0;
  40. int testArray[100];
  41. for(int i=0;i<row;i++){
  42.     for(int j=0;j<col;j++){
  43.  
  44.     cin>>mat[i][j];
  45.  
  46.     }
  47.  
  48.  
  49. }
  50.  
  51.  
  52. //cout<<endl;
  53. int n1=row-1;
  54.  
  55. for(int i=0;i<=n1;i++){
  56.     for(int j=0;j<=n1;j++){
  57.         testArray[0]=mat[i][j];
  58.         //cout<<testArray[0]<<" ";
  59.         testArray[1]=mat[n1-i][j];
  60.         //cout<<testArray[1]<<" ";
  61.         testArray[2]=mat[i][n1-j];
  62.         //cout<<testArray[2]<<" ";
  63.         testArray[3]=mat[n1-i][n1-j];
  64.         //cout<<testArray[3]<<" "<<endl;
  65.         //cout<<Maximum(testArray)<<endl;
  66.         sum=sum+Maximum(testArray);
  67.  
  68.     }
  69.     //cout<<endl;
  70. }
  71.  
  72.  
  73.  
  74. cout<<sum/4<<endl;
  75.  
  76.  
  77.  
  78.  
  79. }
  80.  
  81.  
  82.  
  83.  
  84. return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement