修改文件结构。
This commit is contained in:
25
POP/10/Exercise03.c
Normal file
25
POP/10/Exercise03.c
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
int main() {
|
||||
char inputString[100] = {0};
|
||||
int length = 0, i = 0;
|
||||
bool moved = true;
|
||||
char temp;
|
||||
scanf("%s", inputString);
|
||||
length = strlen(inputString);
|
||||
while (moved) {
|
||||
moved = false;
|
||||
for (int i = 0; i < length-1; i++) {
|
||||
if (inputString[i] < inputString[i+1]) {
|
||||
temp = inputString[i];
|
||||
inputString[i] = inputString[i+1];
|
||||
inputString[i+1] = temp;
|
||||
moved = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("%s\n", inputString);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user