Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int a,b,c,d,e,t,n,i,j,k,r;
- cin>>t;
- for(int x=1;x<=t;x++)
- {
- cin>>n;
- a=0;
- int A[101][101];
- for(i=1;i<=n;i++)
- {
- for(j=1;j<=n;j++)
- {
- cin>>A[i][j];
- }
- }
- for(i=1;i<=n;i++)
- {
- for(j=1;j<=n;j++)
- {
- if(i==j) a+=A[i][j];
- }
- }
- r=0,c=0,k=0,d=0;
- for(i=1;i<=n;i++)
- {
- d=0;
- for(j=1;j<n;j++)
- {
- for(k=j+1;k<=n;k++)
- {
- if(A[i][j]==A[i][k])
- {
- r++;
- d=1;
- break;
- }
- }
- if(d==1) break;
- }
- }
- for(j=1;j<=n;j++)
- {
- d=0;
- for(i=1;i<n;i++)
- {
- for(k=i+1;k<=n;k++)
- {
- if(A[i][j]==A[k][j])
- {
- c++;
- d=1;
- break;
- }
- }
- if(d==1) break;
- }
- }
- cout<<"Case"<<" "<<"#"<<x<<": "<<a<<" "<<r<<" "<<c<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement