jordanov

најголема разлика

Nov 15th, 2019
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include<stdio.h>
  2. #include <stdlib.h>
  3. int main()
  4. {
  5.     int n,a,b, i;
  6.     float sum = 0, x;
  7.  
  8.     printf("Enter number of elements:  ");
  9.     scanf("%d", &n);
  10.     printf("\n\n\nEnter %d elements\n\n", n);
  11.     int max = 0;
  12.     for(i = 0; i < n; i++)
  13.     {
  14.         scanf("%d%d", &a, &b);
  15.         if(a > b)
  16.         {
  17.             sum = a - b;    
  18.         }
  19.         else sum = b-a;
  20.         if(sum > max)
  21.         {
  22.             max = sum;
  23.         }
  24.     }
  25.    
  26.     printf(" %d", max);
  27.     return 0;
  28. }
Add Comment
Please, Sign In to add comment