SHARE
TWEET

Untitled

a guest Feb 17th, 2020 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int n = 4;
  6.     int n1 = n;
  7.     int mass[n][n];
  8.     int i = 0;
  9.     int j=0;
  10.     int k=0;
  11.     int k2=0;
  12.     int sumStr = 0;
  13.     int sumStlb = 0;
  14.     int mainSum1[n];
  15.     int mainSum2[n];
  16.     int sum1 = 0;
  17.     int sum2 = 0;
  18.     for (i = 0; i<n; i++) {
  19.         for (j=0; j<n; j++) {
  20.             printf("vvedite [%d][%d] \n",i,j);
  21.             scanf("%d", &mass[i][j]);
  22.            }
  23.     }
  24.  
  25.     for (i = 0;i<n;i++) {
  26.         printf(" \n");
  27.         for (j=0;j<n;j++) {
  28.             printf("%d ",mass[i][j]);
  29.         }
  30.     }
  31.  
  32.     for (i = 0; i<n; i++) {
  33.         for (j=0; j<n; j++) {
  34.             if (i==j)
  35.             {
  36.                 sum1 = sum1 + mass[i][j];
  37.             }
  38.         }
  39.     }
  40.  
  41.     for (i = 0; i<n; i++) {
  42.         n1--;
  43.         sum2 = sum2 + mass[i][n1];
  44.  
  45.  
  46.     }
  47.  
  48.  
  49. printf("\n");
  50. printf("sum main diagonal = ");
  51. printf("%d", sum1);
  52. printf("\n");
  53. printf("sum not main diagonal = ");
  54. printf("%d\n", sum2);
  55.  
  56.  
  57. for (i = 0; i<n; i++) {
  58.     sumStr = 0;
  59.     for (j=0; j<n; j++) {
  60.         sumStr = sumStr + mass[i][j];
  61.     }
  62.         mainSum2[k2] = sumStr;
  63.         k2++;
  64.  
  65.  
  66. }
  67. k = 0;
  68.  
  69. for (i = 0; i<n; i++) {
  70.     sumStlb = 0;
  71.     for (j=0; j<n; j++) {
  72.         sumStlb = sumStlb + mass[j][i];
  73.     }
  74.         mainSum1[k] = sumStlb;
  75.         k++;
  76.  
  77.  
  78. }
  79.  
  80. for (i=0; i<n; i++){
  81. if (mainSum1[i]==mainSum2[i]){
  82.     printf("Magic");
  83. }
  84.  
  85. else {
  86.     printf("not magic");
  87. }
  88. }
  89.  
  90.  
  91.  
  92. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top