Guest User

Untitled

a guest
Jan 20th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. void AlphabetSoup(char str[]) {
  4. int first = str[0]; // code goes here
  5. int index = 0;
  6. int copy[8];
  7. int current = copy[index];
  8. int k = 0 ;
  9.  
  10.  
  11. for (int i = 0; i < strlen(str); i++) {
  12. if ( str[i] > str[i-1] ) {
  13. copy[0] = str[i-1]; // first character
  14. }
  15. if(i == strlen(str) -1){
  16. printf("%c", copy[0]); // printing the first character
  17. index += 1; // incrementing the str[index]
  18. }
  19. }
  20.  
  21. while (k < strlen(str)){
  22. for (int j = index; j < strlen(str); j++) {
  23. if( str[j] > str[j-1] ) {
  24. current = str[j-1];
  25. }
  26. if(j == strlen(str) - 1){
  27. printf("%c", current);
  28. index += 1;
  29. }
  30. }
  31. k++;
  32. }
  33. }
  34.  
  35.  
  36. int main() {
  37. AlphabetSoup("coderbyte"); // bcdeeorty
  38. }
Add Comment
Please, Sign In to add comment