Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- void AlphabetSoup(char str[]) {
- int first = str[0]; // code goes here
- int index = 0;
- int copy[8];
- int current = copy[index];
- int k = 0 ;
- for (int i = 0; i < strlen(str); i++) {
- if ( str[i] > str[i-1] ) {
- copy[0] = str[i-1]; // first character
- }
- if(i == strlen(str) -1){
- printf("%c", copy[0]); // printing the first character
- index += 1; // incrementing the str[index]
- }
- }
- while (k < strlen(str)){
- for (int j = index; j < strlen(str); j++) {
- if( str[j] > str[j-1] ) {
- current = str[j-1];
- }
- if(j == strlen(str) - 1){
- printf("%c", current);
- index += 1;
- }
- }
- k++;
- }
- }
- int main() {
- AlphabetSoup("coderbyte"); // bcdeeorty
- }
Add Comment
Please, Sign In to add comment