问答题

试题要求如图10.4所示。


#include<stdio.h>
#include<string.h>
char xx[20] [80];
void jsSort()

void main()

readDat();
jsSort();
writeDat();

readDat()

FILE *in;
int i=0;
char *p;
in=fopen("K:\\k06\\35010004\\in.dat", "r");
while(i<20 && fgets(xx[i], 80, in)!=NULL)
p=strchr(xx[i], ’\n’);
if(p) *p=0;
i++;

fclose(in);
writeDat()

FILE *out;
int i;
out=fopen("K:\\k06\\35010004\\out.dat", "w");
for(i=0; i<20; i++)
printf("%s\n", xx[i]);
fprintf(out, "%s\n", xx[i]);

fclose(out);

【参考答案】

void jsSort()
{
int i, j, k, length, half;
ch......

(↓↓↓ 点击下方‘点击查看答案’看完整答案、解析 ↓↓↓)