Advertisement
Guest User

Untitled

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