Hi!!
I need to sort a sting if capital and/or small letters in the orders of letters only, so that a caputal letter is first
example:
input: PrintCapitalLettersBeforeSmallLetters
output: aaaBCeeeeeefiiLLlllmnoPprrrrSsstttttt
I wrote a code but i only manage to order capital letters first:
Code:
#include <stdio.h>
#include <string.h>
int main (void) {
char string[] = "SimplYeAsyLearning";
char temp;
int i, j;
int n = strlen(string);
printf("String before sorting - %s \n", string);
for (i = 0; i < n-1; i++) {
for (j = i+1; j < n; j++) {
if (string[i] > string[j]) {
temp = string[i];
string[i] = string[j];
string[j] = temp;
}
}
}
printf("String after sorting - %s \n", string);
return 0;
}
I need to make another comparison but I dontknow how.
I can only use #include <stdio.h> inside the code
Thank you!