题目
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/a38da524c656f0f54528ce5777e2be7e.png)
解答
#include<stdio.h>
#include<string.h>
void read(FILE *in,char buff[]){
int i=0;
char c;
if(in=fopen("D:\\A.txt","r")){
while(!feof(in)) {
c = fgetc(in);
if(c!='\n'&&c!=' '&&c!=EOF){
buff[i++]=c;
}
}
fclose(in);
}
else{
printf("无法打开文件\n");
}
if(in=fopen("D:\\B.txt","r")){
while(!feof(in)) {
c = fgetc(in);
if(c!='\n'&&c!=' '&&c!=EOF){
buff[i++]=c;
}
}
buff[i]='\0';
fclose(in);
}
else{
printf("无法打开文件\n");
}
}
void storage(FILE *out,char buff[]){
int i;
if(out=fopen("D:\\C.txt","w")){
fwrite(buff,strlen(buff),1,out);
printf("写入成功\n");
fclose(out);
}else{
printf("无法打开文件\n");
}
}
void QSort(char buff[],int low,int high){
int i,j,tmp;
i=low,j=high;
if(i<j){
tmp=buff[i];
while(i<j){
while(i<j&&buff[j]>=tmp)
j--;
buff[i]=buff[j];
while(i<j&&buff[i]<=tmp)
i++;
buff[j]=buff[i];
}
buff[i]=tmp;
QSort(buff,low,i-1);
QSort(buff,i+1,high);
}
}
void main(){
FILE *in=NULL,*out=NULL;
char buff[255];
int len;
read(in,buff);
len=strlen(buff);
QSort(buff,0,len-1);
storage(out,buff);
}