第1个回答 推荐于2018-05-06
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void inOrder(char array[], int n );
int main(int argc, char *argv[])
{
char temp[100];
printf("请输入字符串:\n");
gets(temp);
char a[strlen(temp)+1];
strcpy(a,temp);
inOrder(a,strlen(temp));
int k;
for(k=0; k<strlen(temp); k++)
{
printf("%c",a[k]);
}
system("pause");
return 0;
}
//选择法排序函数
void inOrder(char array[], int n)
{
int i, j;
char temp;
for(i=0; i<n-1; i++)
{
for(j=i+1; j<n; j++)
{
if(array[j]>array[i])
{
temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
}
}
在DEV C++中编写可用,temp数组只是暂时存放输入字符串的,它的大小可根据你实际需要调大调小。本回答被提问者采纳