首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
函数readDat()实现从文件in.dat中读取20行数据并存放到字符串数组xx中(每行字符串长度均小于80)。请编写函数jsSort()。其函数的功能是:以行为单位对字符申变量的下标为奇数的位置上的字符按其ASCII码值从小到大的顺序进行排序,下标为偶
函数readDat()实现从文件in.dat中读取20行数据并存放到字符串数组xx中(每行字符串长度均小于80)。请编写函数jsSort()。其函数的功能是:以行为单位对字符申变量的下标为奇数的位置上的字符按其ASCII码值从小到大的顺序进行排序,下标为偶
admin
2013-12-10
16
问题
函数readDat()实现从文件in.dat中读取20行数据并存放到字符串数组xx中(每行字符串长度均小于80)。请编写函数jsSort()。其函数的功能是:以行为单位对字符申变量的下标为奇数的位置上的字符按其ASCII码值从小到大的顺序进行排序,下标为偶数的位置上的字符仍按原来位置存放,排序后的结果仍按行重新存人字符串数组xx中,最后调用函数writeDat()把结果XX输出到out.dat文件中。
例如:位置0 1 2 3 4 5 6 7
原字符串h g f e d C b a
处理后字符串h a f e d e b g
【试题程序】
#include
#include
char xx[20][80];
void readDat();
void writeDat();
void jsSort()
{
}
void main()
{
readDat();
jsSort();
writeDat();
}
void readDat()
{
FILE*in;
int i=0;
char*P;
in=fopen(“in.dat”,“r”);
while(i<20&&fgets(XX
,80,in)!=NULL){
p=strchr(xx
,‘\n’);
if(p)*p=0;
i++;
}
fclose(in);
}
void writeDat()
{
FILE*out;
int i;
out=fopen(“out.dat”,“W”);
for(i=0,i<20;i++){
printf(“%s\n”,xx
);
fprintf(out,“%s\n”,xxEi]);
}
fclose(out);
}
选项
答案
void jsSort() {unsigned int i,j,k} /*定义变量*/ int temp} for(i=0;i<20;i++) for(j=1;j
xx[i][k]) {temp=xxEiJEj]; xx[i][j]==xx[i][k]; xx[i][k]=temp; } }
解析
转载请注明原文地址:https://kaotiyun.com/show/bElZ777K
本试题收录于:
三级数据库技术题库NCRE全国计算机三级分类
0
三级数据库技术
NCRE全国计算机三级
相关试题推荐
下面不属于DBMS的数据操纵方面的程序模块的是
启动外围设备前必须组织好通道程序,下列哪一项不是通道程序的控制部件?
当前应用开发工具的发展趋势是采用三层CIS结构、【】、开放的构件式的分布式计算环境。
若一棵二叉树中只有叶节点和左、右子树皆非空的节点,设叶节点的个数为1,则左、右子树皆非空的节点个数为【】。
以层次模型建立的数据库系统,其主要代表是
下面关于数据库系统基于日志的恢复的叙述中,哪一种说法是正确的?
在数据库中,产生数据不一致的根本原因是
数据库功能可以分为两部分:前端和后端。前端与后端之间通过【】或应用程序来接口。
用二维表结构表示实体以及实体间联系的数据模型称为【】数据模型。
随机试题
良好的声誉风险管理有助于提升商业银行的盈利能力和实现长期战略目标,下列可能诱发商业银行声誉风险的有()。
下列属于广义学习内涵特点的有()。
公共关系与人际关系的联系与区别。
材料:鸦片战争以后,中国逐步成为半殖民地半封建社会,列强对中国的侵略步步紧逼,封建统治日益腐败,祖国山河破碎、战乱不已,人民饥寒交迫、备受奴役。救亡图存的民族使命迫在眉睫。争取民族独立、人民解放,实现国家富强、人民富裕,成为中国人民必须完成的历史任务。
关于启动子和启动序列的说法错误的是
根据《药品管理法》规定违法生产、销售药品货值金额二倍以上五倍以下的罚款不包括
患者,男,56岁。肥胖,无“三多一少”症状,尿糖阳性,空腹血糖正常。为明确诊断,应做的检查是()
Alandfreefromdestruction,pluswealth,naturalresources,andlaborsupply—allthesewereimportantfactors,inhelpingEngl
设函数f(x)满足关系式f"(x)+[f’(x)]2=x,且f’(0)=0,则()
在考生文件夹中有一个工程文件sjt3.vbp。运行程序时,先向文本框Text1中输入一个不超过10的正整数,然后选择“N的阶乘”或“(N+2)的阶乘”单选钮,即可进行计算,计算结果在文本框Text2中显示,如图所示。在给出的窗体文件中已经添加了全部控件,但
最新回复
(
0
)