1个回答
展开全部
#include <stdio.h>
#include <string.h>
int main()
{
FILE *fp1 = NULL;
FILE *fp2 = NULL;
FILE *fp3 = NULL;
char buf1[100] = {0};
char buf2[100] = {0};
char buf3[200] = {0};
int i;
int j;
int length;
char temp;
fp1 = fopen("A.txt", "r");
fp2 = fopen("B.txt", "r");
fp3 = fopen("C.txt", "w");
fgets(buf1, 99, fp1);
fgets(buf2, 99, fp2);
strcpy(buf3, buf1);
strcat(buf3, buf2);
length = strlen(buf3);
for(i=0;i<length-1;i++)
{
for(j=i+1;j<length;j++)
{
if(buf3[i]>buf3[j])
{
temp = buf3[i];
buf3[i] = buf3[j];
buf3[j] = temp;
}
}
}
fputs(buf3, fp3);
fclose(fp3);
fclose(fp2);
fclose(fp1);
return 0;
}
#include <string.h>
int main()
{
FILE *fp1 = NULL;
FILE *fp2 = NULL;
FILE *fp3 = NULL;
char buf1[100] = {0};
char buf2[100] = {0};
char buf3[200] = {0};
int i;
int j;
int length;
char temp;
fp1 = fopen("A.txt", "r");
fp2 = fopen("B.txt", "r");
fp3 = fopen("C.txt", "w");
fgets(buf1, 99, fp1);
fgets(buf2, 99, fp2);
strcpy(buf3, buf1);
strcat(buf3, buf2);
length = strlen(buf3);
for(i=0;i<length-1;i++)
{
for(j=i+1;j<length;j++)
{
if(buf3[i]>buf3[j])
{
temp = buf3[i];
buf3[i] = buf3[j];
buf3[j] = temp;
}
}
}
fputs(buf3, fp3);
fclose(fp3);
fclose(fp2);
fclose(fp1);
return 0;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询