linus666

Untitled

May 5th, 2024 (edited)
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.65 KB | Software | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.    int size, x, c, i = 0;
  6.    scanf("%d", &size);
  7.    
  8.    while (i < size)
  9.    {
  10.     if (i == 0)
  11.     {
  12.         scanf("%d", &x);
  13.         c = x;
  14.         i += 1;
  15.         printf("%d ", x);
  16.     }
  17.     scanf("%d", &x);
  18.     if (c != x)
  19.     {
  20.         if (c > x)
  21.         {
  22.             printf("%d ", c);
  23.             c = x;
  24.             i += 1;
  25.  
  26.         }
  27.         else if (x > c)
  28.         {
  29.             printf("%d ", x);
  30.             c = x;
  31.             i += 1;
  32.  
  33.         }
  34.         else
  35.         {
  36.             printf("%d " , x);
  37.             c = x;
  38.             i += 1;
  39.  
  40.         }
  41.  
  42.     }
  43.    }
  44.    
  45.    return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment