Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int size, x, c, i = 0;
- scanf("%d", &size);
- while (i < size)
- {
- if (i == 0)
- {
- scanf("%d", &x);
- c = x;
- i += 1;
- printf("%d ", x);
- }
- scanf("%d", &x);
- if (c != x)
- {
- if (c > x)
- {
- printf("%d ", c);
- c = x;
- i += 1;
- }
- else if (x > c)
- {
- printf("%d ", x);
- c = x;
- i += 1;
- }
- else
- {
- printf("%d " , x);
- c = x;
- i += 1;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment