函数readDat()的功能是从文件in52.dat中读取20行数据存放到字符串数组xx中(每行字符串的长度均小于80)。请编制函数JsSod(),该函数的功能是:以行为单位对字符串变量的—F标为奇数位置上的字符按其 ASCII值从小到大的顺序进行排序,排序后的结果仍按行重新存入字符串数组xx中,最后调用函数writeDat()把结果xx输出到文件out52.dat中。
例如: 位置 0 1 2 3 4 5 6 7
源字符串 h g f e d c b a
则处理后字符串 h a f c d e b g。
注意:部分源程序已给出。
请勿改动主函数main()、读函数readDat()和写函数writeDat()的内容。
试题程序:
#include<stdio. h>
#include<string. h>
#include<conio. h>
char xx[20] [80];void jsSort
void main ()
readDat ();
jsSort ( );
writeDat ();
readDat ( )
FILE *in;
int i=0;
char *p;
in=fopen ( "in52. dat", "r" );
while(i<20 && fgets(xx[i],80,in) !=NULL)
p=strchr (xx[i], ’ In’ );
if(p) *p=0;
i++;
fclose (in);
writeDat ()
FILE *out;
int i;
out=fopen ("out52 .dat", "w");
clrscr ( );
for (i=0;i<20;i++)
printf ("%s\n", xx [i] );
fprint f (out, "%s\n", xx [i] );
fclose (out);