Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5.  
  6.  
  7. int main()
  8. {
  9. int n, i, j;
  10. scanf("%d", &n);
  11. float A[50][50], B[50][50], y = 0.0, x = 0.0;
  12.  
  13. for (i=0; i<n; i++)
  14. for (j=0; j<n; j++)
  15. scanf("%f", &A[i][j]);
  16.  
  17. for (i=0; i<n; i++)
  18. {
  19. for (j=0; j<n; j++)
  20. {
  21. if(i>j)
  22. x += A[i][j];
  23.  
  24.  
  25. if (i+j>n-1)
  26. y += A[i][j];
  27. }
  28. }
  29.  
  30. for (i=0; i<n; i++)
  31. {
  32. for (j=0; j<n; j++)
  33. {
  34. if (i==j && i+j==n-1)
  35. B[i][j] = x+y;
  36.  
  37. else if (i==j)
  38. B[i][j] = x;
  39. else if (i+j == n-1)
  40. B[i][j] = y;
  41.  
  42.  
  43.  
  44. else
  45. B[i][j] = 0;
  46. }
  47. }
  48. for (i=0; i<n; i++){
  49. for (j=0; j<n; j++){
  50. printf("%.1f ", B[i][j]);
  51. }
  52. printf("\n");
  53. }
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement