Guest User

Untitled

a guest
Jan 10th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. int magico(int a[20][20], int n)
  2. {
  3. int i, j, ls=0, cs=0, dp=0, ds=0;
  4.  
  5. for(i=0; i<n; i++){
  6. dp+=a[i][j];
  7. }
  8. for(i=0; i<n; i++){
  9. ds+=a[i][n-1-i];
  10. }
  11. //linhas
  12. for(i=0; i<n; i++){
  13. for(j=0; j<n; j++){
  14. ls+=a[i][j];
  15. }
  16. }
  17. //colunas
  18. for(j=0; j<n; i++){
  19. for(i=0; i<n; j++){
  20. cs+=a[i][j];
  21. }
  22. }
  23. if(dp==ds && ds==ls && ls==cs)
  24. return 1;
  25. else return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment