[计算机类试卷]国家三级(网络技术)机试模拟试卷298及答案与解析.doc

上传人:terrorscript155 文档编号:495819 上传时间:2018-11-28 格式:DOC 页数:4 大小:27.50KB
下载 相关 举报
[计算机类试卷]国家三级(网络技术)机试模拟试卷298及答案与解析.doc_第1页
第1页 / 共4页
[计算机类试卷]国家三级(网络技术)机试模拟试卷298及答案与解析.doc_第2页
第2页 / 共4页
[计算机类试卷]国家三级(网络技术)机试模拟试卷298及答案与解析.doc_第3页
第3页 / 共4页
[计算机类试卷]国家三级(网络技术)机试模拟试卷298及答案与解析.doc_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家三级(网络技术)机试模拟试卷 298及答案与解析 一、程序设计题 1 已知在文件 IN DAT中存有 100个产品销售记录,每个产品销售记录有产品代码 dm(字符型 4位 ),产品名称 mc(字符型 10位 )、单价 dj(整型 )、数量 sl(整型 )、金额 je(长整型 )五部分组成。其中;金额一单价 *数量计算得出。函数 ReadDat()是读取这 100个销售记录并存人结构数组 sell中。请编制函数 SortDat(),其功能要求;按金额从小到大进行排列,若金额相同,则按产品代码从大到小进行排列,最终结构仍存人结构数组 sell中,最后调用函数 WriteDat()把结构输出到文

2、件OUT2 DAT中。 注意;部分源程序已给出。 请勿改动主函数 main()、读数据函数 ReadDat()和输出数据函数 WriteDat()的内容。 试题程序; #include #include #include #include #define MAX 100 typedef struct char dm5;产品代码 char mc11;产品名称 int dj;单价 int sl; 数量 long je; 金额 PRO; PRO sellMAX; void ReadDat(); void WriteDat(); void SortDat() void main() memset(se

3、ll, 0, sizeof(sell); ReadDat(); SortDat(); WriteDat(); void ReadDat() FILE*fp; char str80, ch11; int i; fp=fopen(“IN DAT“, “r“); for(i=0; isellj je|(selli je=sellj je&strcmp(seni dm,sellj dm)0) *将以 &selli为起始地址大小为 sizeof(temp)的内存中的内容复制到以 &temp为起始地址的内存中 * memcpy(&temp, &selli, sizeof(temp); memcpy(&se

4、lli, &sellj, sizeof(temp); memcpy(&sellj, &temp, sizeof(temp); 【试题解析】 本题主要考查结构数组排序的问题。所谓结构数组排序就是以结构某一元素为依据对结构数组进行排序。排序的思 想是 (以从小到大为例 );将当前数据与其后的各个数据相比较,如果当前的数据比其后的数据大,则将两数据进行交换,从而使得前面的数据小于后面的数据,达到从小到大排序的目的。由于结构不像变量那样可以通过简单的赋值来交换变量 (如果要赋值的话需要对结构里的所有元素进行赋值替换,比较麻烦 ),所以在进行两个相邻结构交换时,用到内存拷贝函数来对内存的内容整体进行操作。

展开阅读全文
相关资源
猜你喜欢
  • ASTM A928 A928M-2014 Standard Specification for Ferritic Austenitic &40 Duplex&41 Stainless Steel Pipe Electric Fusion Welded with Addition of Filler Metal《具有填充金属的铁素体 奥氏体 (双相) 不锈钢管.pdf ASTM A928 A928M-2014 Standard Specification for Ferritic Austenitic &40 Duplex&41 Stainless Steel Pipe Electric Fusion Welded with Addition of Filler Metal《具有填充金属的铁素体 奥氏体 (双相) 不锈钢管.pdf
  • ASTM A929 A929M-2001(2007) Standard Specification for Steel Sheet Metallic-Coated by the Hot-Dip Process for Corrugated Steel Pipe《波纹钢管用的经热浸处理的金属涂覆薄钢板的标准规范》.pdf ASTM A929 A929M-2001(2007) Standard Specification for Steel Sheet Metallic-Coated by the Hot-Dip Process for Corrugated Steel Pipe《波纹钢管用的经热浸处理的金属涂覆薄钢板的标准规范》.pdf
  • ASTM A929 A929M-2001(2013) Standard Specification for Steel Sheet Metallic-Coated by the Hot-Dip Process for Corrugated Steel Pipe《波纹钢管用经热浸处理的金属涂覆薄钢板标准规格》.pdf ASTM A929 A929M-2001(2013) Standard Specification for Steel Sheet Metallic-Coated by the Hot-Dip Process for Corrugated Steel Pipe《波纹钢管用经热浸处理的金属涂覆薄钢板标准规格》.pdf
  • ASTM A929 A929M-2017 Standard Specification for Steel Sheet Metallic-Coated by the Hot-Dip Process for Corrugated Steel Pipe《用于波纹钢管的热浸镀工艺的金属涂覆钢板的标准规格》.pdf ASTM A929 A929M-2017 Standard Specification for Steel Sheet Metallic-Coated by the Hot-Dip Process for Corrugated Steel Pipe《用于波纹钢管的热浸镀工艺的金属涂覆钢板的标准规格》.pdf
  • ASTM A929 A929M-2018 Standard Specification for Steel Sheet Metallic-Coated by the Hot-Dip Process for Corrugated Steel Pipe.pdf ASTM A929 A929M-2018 Standard Specification for Steel Sheet Metallic-Coated by the Hot-Dip Process for Corrugated Steel Pipe.pdf
  • ASTM A930-2003 Standard Practice for Life-Cycle Cost Analysis of Corrugated Metal Pipe Used for Culverts Storm Sewers and Other Buried Conduits《涵洞、雨水管道和其它地下管道用波纹形金属管寿命周期成本分析的标准实施.pdf ASTM A930-2003 Standard Practice for Life-Cycle Cost Analysis of Corrugated Metal Pipe Used for Culverts Storm Sewers and Other Buried Conduits《涵洞、雨水管道和其它地下管道用波纹形金属管寿命周期成本分析的标准实施.pdf
  • ASTM A930-2009 Standard Practice for Life-Cycle Cost Analysis of Corrugated Metal Pipe Used for Culverts Storm Sewers and Other Buried Conduits《涵洞、雨水管道和其它地下管道用波纹形金属管寿命周期成本分析的标准实施.pdf ASTM A930-2009 Standard Practice for Life-Cycle Cost Analysis of Corrugated Metal Pipe Used for Culverts Storm Sewers and Other Buried Conduits《涵洞、雨水管道和其它地下管道用波纹形金属管寿命周期成本分析的标准实施.pdf
  • ASTM A930-2009(2014) Standard Practice for Life-Cycle Cost Analysis of Corrugated Metal Pipe Used for Culverts Storm Sewers and Other Buried Conduits《涵洞 暴雨下水道和其它地下的排水道用波形金属管的寿命周期费用.pdf ASTM A930-2009(2014) Standard Practice for Life-Cycle Cost Analysis of Corrugated Metal Pipe Used for Culverts Storm Sewers and Other Buried Conduits《涵洞 暴雨下水道和其它地下的排水道用波形金属管的寿命周期费用.pdf
  • ASTM A931-1996(2002) Standard Test Method for Tension Testing of Wire Ropes and Strand《金属丝绳和绞线拉伸试验的标准试验方法》.pdf ASTM A931-1996(2002) Standard Test Method for Tension Testing of Wire Ropes and Strand《金属丝绳和绞线拉伸试验的标准试验方法》.pdf
  • 相关搜索

    当前位置:首页 > 考试资料 > 职业资格

    copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
    备案/许可证编号:苏ICP备17064731号-1