Advertisement
LegoDrifter

Neznam kako ja reshiv ama ubo e vo D stavi go max-min clenot

Jan 20th, 2020
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.12 KB | None | 0 0
  1. #include <stdio.h>
  2. void main()
  3. {
  4.     int m[50][50],n,j,i,min,max;
  5.     scanf("%d",&n);
  6.     for(i=0;i<n;i++)
  7.     {
  8.         for(j=0;j<n;j++)
  9.         {
  10.             printf("Element [%d][%d]:",i,j);
  11.             scanf("%d",&m[i][j]);
  12.         }
  13.     }
  14.     for(i=0;i<n;i++)
  15.     {
  16.         for(j=0;j<n;j++)
  17.         {
  18.             printf("%d  ",m[i][j]);
  19.         }
  20.         printf("\n");
  21.     }
  22.     for(i=0;i<n;i++)
  23.     {
  24.         for(j=0;j<n;j++)
  25.         {
  26.             if(i==0&&j==0)
  27.             {
  28.                 min=max=m[i][j];
  29.             }
  30.             else if(m[i][j]>max)
  31.             {
  32.                 max=m[i][j];
  33.             }
  34.             else if(m[i][j]<min)
  35.             {
  36.                 min=m[i][j];
  37.             }
  38.         }
  39.     }
  40.     for(i=0;i<n;i++)
  41.     {
  42.         for(j=0;j<n;j++)
  43.         {
  44.         if(j==i)
  45.         {
  46.             m[i][j]=max-min;
  47.         }
  48.         }
  49.  
  50.     }
  51.     for(i=0;i<n;i++)
  52.     {
  53.         for(j=0;j<n;j++)
  54.         {
  55.             printf("%d  ",m[i][j]);
  56.         }
  57.         printf("\n");
  58.     }
  59.     printf("%Ispecati go najgolemiot element %d, a najmaliot %d",max,min);
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement