Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int magico(int a[20][20], int n)
- {
- int i, j, ls=0, cs=0, dp=0, ds=0;
- for(i=0; i<n; i++){
- dp+=a[i][j];
- }
- for(i=0; i<n; i++){
- ds+=a[i][n-1-i];
- }
- //linhas
- for(i=0; i<n; i++){
- for(j=0; j<n; j++){
- ls+=a[i][j];
- }
- }
- //colunas
- for(j=0; j<n; i++){
- for(i=0; i<n; j++){
- cs+=a[i][j];
- }
- }
- if(dp==ds && ds==ls && ls==cs)
- return 1;
- else return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment