Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define bool int
  4. #define true 1
  5. #define false 0
  6.  
  7. void f_sequence(char str[]);
  8.  
  9. void f_sequence(char str[])
  10. {
  11. bool reallyUp = true;
  12. bool up = true;
  13. bool reallyDown = true;
  14. bool down = true;
  15. bool none = true;
  16. for(int i = 0; strlen(str) - 1; i++)
  17. {
  18. if((int)str[i+1] == (int)str[i])
  19. {
  20. reallyUp = false;
  21. reallyDown = false;
  22. }
  23. else if((int)str[i+1] > (int)str[i])
  24. {
  25. down = false;
  26. }
  27. else
  28. {
  29. up = false;
  30. }
  31. }
  32.  
  33. if(reallyUp)
  34. printf("The string %s is in real inreasing order\n",str);
  35. else if(reallyDown)
  36. printf("The string %s is in real decreasing order!\n",str);
  37. else if(up)
  38. printf("The string %s is in increasing order!\n",str);
  39. else if(down)
  40. printf("The string %s is in decreasing order!\n",str);
  41. else
  42. printf("The string %s has random order\n",str);
  43.  
  44. }
  45.  
  46. int main(int argc, char** argv)
  47. {
  48.  
  49. char string[100];
  50. printf("Please enter your string:\n");
  51. scanf("%20s",string);
  52. f_sequence(string);
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement