Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- zad 7.33.c
- #include <stdio.h>
- #include <math.h>
- #include <time.h>
- #include <stdlib.h>
- int clamp(int v, int lo, int hi)
- {
- int res;
- if(v<lo)
- res=lo;
- else if(v>hi)
- res=hi;
- else
- res=v;
- return(res);
- }
- int main()
- {
- int num,up,down,temp,result;
- printf("Podaj liczbe: ");
- scanf("%d",&num);
- printf("Podaj 1 granice: ");
- scanf("%d",&up);
- printf("Podaj 2 granice: ");
- scanf("%d",&down);
- if(down>up)
- {
- temp=up;
- up=down;
- down=temp;
- }
- result=clamp(num,down,up);
- printf("%d",result);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement