首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
函数readDat()实现从数据文件in.dat中读取20行数据存放到字符串数组XX中(每行字符串长度均小于80)。请编写函数jsSort()。其功能是:以行为单位对字符串按下面给定的条件进行排序,排序后的结果仍按行重新存入字符串数组XX中。最后调用函数w
函数readDat()实现从数据文件in.dat中读取20行数据存放到字符串数组XX中(每行字符串长度均小于80)。请编写函数jsSort()。其功能是:以行为单位对字符串按下面给定的条件进行排序,排序后的结果仍按行重新存入字符串数组XX中。最后调用函数w
admin
2013-12-10
18
问题
函数readDat()实现从数据文件in.dat中读取20行数据存放到字符串数组XX中(每行字符串长度均小于80)。请编写函数jsSort()。其功能是:以行为单位对字符串按下面给定的条件进行排序,排序后的结果仍按行重新存入字符串数组XX中。最后调用函数writeDat()把结果XX输m到文件out.dat中。条件:从中间位置开始,将字符串分成两部分,左边部分按字符的ASCII码值降序排序,右边部分按字符的ASCII码值升序排序。如果原字符串长度为奇数,则最中间的字符不参加排序,字符仍存放在原位置上。
例如:位置0 1 2 3 4 5 6 7 8
原字符串 a b C d h g f e
1 2 3 4 9 8 7 6 5
处理后字符串d C b a e f g h
4 3 2 1 9 5 6 7 8
【试题程序】
#include
#include
char xxE20][80];
void readDat();
void writeDat();
void jsSort()
{
jsSort();
writeDat();
}
void readDat()
{
FILE*in;
int i=0;
char*P;
in=fopen(“in.dat”,“r”)1
while(i<20 8L~fgets(xx[-i],80,in)!
NULL){
p=strehr(xx
,\n);
if(p)*p=0}
i++;
}
fclose(in);
}
void writeDat()
{
FILE*out}
int i;
Outofopen(“out.dat”,“W”);
for(i=0;i<20;i++){
printf(“%s\n”,xx
);
fprintf(out,“%s\n”,xx
);
}
fclose(out);
}
选项
答案
void jsSort() (unsigned int i,j,k; /*定义变量*/ int temp; for(i=0;i<20li++) {for(j=0;j
xx[i][k]) {temp=xx[i][i]; xx[i][j]=xxi[i][k]; xx[i][kJ==tempt } } }
解析
转载请注明原文地址:https://kaotiyun.com/show/cElZ777K
本试题收录于:
三级数据库技术题库NCRE全国计算机三级分类
0
三级数据库技术
NCRE全国计算机三级
相关试题推荐
若让元素1,2,3依次进栈,则出栈次序不可能出现哪一种情况?
下面所列的条目中Ⅰ.语法检查Ⅱ.语义检查Ⅲ.用户存取权限检查Ⅳ.数据完整性检查当用户发出查询数据库数据的命令时,数据库管理系统需要进行的检查是
UNIX系统中,文件存储器的管理采用的是
设有栈S和队列Q,其初始状态为空,元素a1、a2、a3、a4、a5、a6依次入栈,出栈的元素则进入队列Q,若6个元素出列的顺序是a2、a4、03、a6、a5、a1,则栈的容量至少是多大?
关于计算机的操作系统,下面叙述不正确的是
下面关于超文本的叙述中,不正确的是
【】不允许关系模式的属性之间有这样的非平凡函数依赖X→Y,其中X不包含码,Y是非主屑性。
用二维表结构表示实体以及实体间联系的数据模型称为【】数据模型。
Internet上的计算机地址有两种表示形式:【】与域名。
有一个网络数据库应用系统,其中一台计算机A存有DBMS软件、所有用户数据和应用程序,其余各节点作为终端通过通信线路向A发出数据库应用请求,这种方式属于
随机试题
某井使用CYJ5—2.1—13HB型抽油机,泵挂深度=1000mm,连杆长度L=1800mm,曲柄半径r=495mm,冲程S=1.4m,冲数n=9次/min,抽油杆柱在空气中的重力Wr=23800N,在相对密度=0.933的液体中的重力W’r=21000N
导体对电流的阻碍作用称为电阻。
A.减少房水生成B.睫状肌痉挛C.减慢心率D.增加房水排出E.浓缩玻璃体高渗药的作用机制是
首选方是:若伴见倦怠乏力,气短懒言,心悸少寐。方选:
肾盂肾炎的主要感染途径为
关于刑事诉讼价值的理解,下列哪一选项是错误的?(2015年卷二22题)
下列人员中,可以担任破产案件中的管理人的是()。
根据下面材料回答问题。下列哪类人员2009年网民人数比上年有所减少?
$10,000
Mywifeisoutofworknow,sowehaveto______ourlivingexpenses.
最新回复
(
0
)