Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #define bool int
- #define true 1
- #define false 0
- void f_sequence(char str[]);
- void f_sequence(char str[])
- {
- bool reallyUp = true;
- bool up = true;
- bool reallyDown = true;
- bool down = true;
- bool none = true;
- for(int i = 0; strlen(str) - 1; i++)
- {
- if((int)str[i+1] == (int)str[i])
- {
- reallyUp = false;
- reallyDown = false;
- }
- else if((int)str[i+1] > (int)str[i])
- {
- down = false;
- }
- else
- {
- up = false;
- }
- }
- if(reallyUp)
- printf("The string %s is in real inreasing order\n",str);
- else if(reallyDown)
- printf("The string %s is in real decreasing order!\n",str);
- else if(up)
- printf("The string %s is in increasing order!\n",str);
- else if(down)
- printf("The string %s is in decreasing order!\n",str);
- else
- printf("The string %s has random order\n",str);
- }
- int main(int argc, char** argv)
- {
- char string[100];
- printf("Please enter your string:\n");
- scanf("%20s",string);
- f_sequence(string);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement