题目内容
函数readDat()的功能是从文件in52.dat中读取20行数据存放到字符串数组xx中(每行字符串的长度均小于80)。请编制函数JsSort(),该函数的功能是:以行为单位对字符串变量的下标为奇数位置上的字符按其ASCII值从小到大的顺序进行排序,排序后的结果仍按行重新存入字符串数组xx中,最后调用函数 wfiteDat()把结果xx输出到文件out52.dat中。
例如: 位置 0 1 2 3 4 5 6 7
源字符串 h S f e d c b a
则处理后字符串 h a f c d e b g。
注意:部分源程序已给出。
请勿改动主函数main()、读函数readDat()和写.函数writeD6L()的内容。
试题程序:
include
include
include
char XX[20][80];
void isSort()
{
}
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],'\n');
if(p) ap=0;
i++;
}
fclose(in);
}
writeDat ()
{
FILE *out;
int i;
ut=fopen("out52.dat","w");
clrscr();
for(i=0;i<20;i++)
{
printf("%s\n",xx[i]);
fprintf(out,"%s\n",xx[i]);
}
fclose(out);
}
查看答案
搜索结果不匹配?点我反馈
更多问题