Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int isSorted(unsigned t[], int n)
- {
- int i, type;
- if(t[0]<=t[1]) type=0;
- else type=1;
- for(i=1; i<n-1; i++)
- {
- if((type==0) && !(t[i]<=t[i+1]))
- return 0;
- if((type==1) && !(t[i]>=t[i+1]))
- return 0;
- }
- return 1;
- }
- #define n 5
- int main()
- {
- unsigned t[n]={1, 3, 5, 7, 9};
- printf("%d", isSorted(t, n));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement