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

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

1、国家三级(网络技术)机试模拟试卷 67及答案与解析 一、程序设计题 1 下列程序的功能是:选出 5000以下符合条件的自然数。条件是:千位数字与百位数字之和等于十位数字与个位数字之和,且千位数字与百位数字之和等于个位数字与千位数字之差的 10倍。计算并输出这些 4位自然数的个数 cnt及这些数的和sum。请编写函数 countValue()实现程序的要求,最后调用函数 wfiteDAT()把结果cnt和 sum输出到文件 OUT67.DAT中。 注意:部分源程序已给出。 请勿改动主函数 main()和写函数 writDAT()的内容。 试题程序: #include stdio.h int cn

2、t,sum; void countValue() void main() cnt=sum=0; countValue (); printf (“满足条件的自然数的个数 =%dn“, cnt); printf (“满足条件的自然的值的和 =%dn“, sum); writeDAT (); writeDAT ( ) FILE *fp; fp=fopen ( “OUT67. DAT“ , “w“ ); fprintf (fp, “%dn%dn“, cnt, sum); fclose fp); 国家三级(网络技术)机试模拟试卷 67答案与解析 一、程序设计题 1 【正确答案】 void countVa

3、lue() int i, thou, hun, ten, data; for (i=5000; i =1000; i-) t hou=i/1000; /*求四位数的千位数字 */ hun=i%1000/100; /*求四位数的百位数字 */ ten=i%100/10; /*求四位数的十位数字 */ dat a=i%l 0; /*求四位数的个位数字 */ if (thou+hun=ten+data /*则统计满足条件的数的个数 */ sum+=i; /*将满足条件的数求和 */ 【试题解析】 本题考查的知识点如下: (1) “%” 与 “/”的使用。 (2)判断结构中多个条件的布尔运算。 (3)循环结构的使用。 本题要求选出 5000以下符合条件的 4位数,所以选择范围是 1000到 5000。这里要借助运算符 “%” 与 “/”将 4位数各位上的数拆成独立的数字:将 1个 4位数整除1000则可得到其千位上的数字,除以 1000取余再整除 100则可得百位上的数字,除以 100取余再 整除 10则可得十位上的数字,除以 10取余则得个位卜的数字。题巾给出的两个条件都要满足,所以两条件之间用 “与 ”运算。使用循环结构对1000到 5000之间的数依次进行上述的处理。

展开阅读全文
相关资源
猜你喜欢
  • ASD-STAN PREN 3511-1999 Aerospace Series Steel FE-PL1801 (100Cr6) Vacuum Induction Melted and Consumable Electrode Remelted Softened Bar for the Manufacture of Machined Bearings a .pdf ASD-STAN PREN 3511-1999 Aerospace Series Steel FE-PL1801 (100Cr6) Vacuum Induction Melted and Consumable Electrode Remelted Softened Bar for the Manufacture of Machined Bearings a .pdf
  • ASD-STAN PREN 3512-1999 Aerospace Series Steel FE-PL1801 (100Cr6) Vacuum Induction Melted and Consumable Electrode Remelted Hardened and Tempered Hollow Bars for the Manufacture of.pdf ASD-STAN PREN 3512-1999 Aerospace Series Steel FE-PL1801 (100Cr6) Vacuum Induction Melted and Consumable Electrode Remelted Hardened and Tempered Hollow Bars for the Manufacture of.pdf
  • ASD-STAN PREN 3513-1988 Aerospace Series Steel FE-PL711 Hardened and Tempered 900 Less Than or Equal to Rm Less Than or Equal to 1100 MPa Bar and Wire De Less Than or Equal to 45 m.pdf ASD-STAN PREN 3513-1988 Aerospace Series Steel FE-PL711 Hardened and Tempered 900 Less Than or Equal to Rm Less Than or Equal to 1100 MPa Bar and Wire De Less Than or Equal to 45 m.pdf
  • ASD-STAN PREN 3514-1988 Aerospace Series Steel FE-PL711 Hardened and Tempered 1100 Less Than or Equal to Rm Less Than or Equal to 1300 MPa Bar and Wire for Bolts De Less Than or Eq.pdf ASD-STAN PREN 3514-1988 Aerospace Series Steel FE-PL711 Hardened and Tempered 1100 Less Than or Equal to Rm Less Than or Equal to 1300 MPa Bar and Wire for Bolts De Less Than or Eq.pdf
  • ASD-STAN PREN 3515-1998 Aerospace Series Steel FE-PL8201 (41NiCrMo2) Air Melted Hardened and Tempered Forgings De Less Than or Equal to 25 mm 1 100 MPa Less Than or Equal to Rm Les.pdf ASD-STAN PREN 3515-1998 Aerospace Series Steel FE-PL8201 (41NiCrMo2) Air Melted Hardened and Tempered Forgings De Less Than or Equal to 25 mm 1 100 MPa Less Than or Equal to Rm Les.pdf
  • ASD-STAN PREN 3516-1998 Aerospace Series Steel FE-PL8201 (41NiCrMo2) Air Melted Softened Forging Stock a or D Less Than or Equal to 300 mm (Edition P2)《航空航天系列 a或D≤300mm的FE-PL8201(4.pdf ASD-STAN PREN 3516-1998 Aerospace Series Steel FE-PL8201 (41NiCrMo2) Air Melted Softened Forging Stock a or D Less Than or Equal to 300 mm (Edition P2)《航空航天系列 a或D≤300mm的FE-PL8201(4.pdf
  • ASD-STAN PREN 3517-1994 Aerospace Series Steel FE-PL2105 Air Melted Hardened and Tempered Bar for Machining De Less Than or Equal to 150 mm 1080 MPa Less Than or Equal to Rm Less T.pdf ASD-STAN PREN 3517-1994 Aerospace Series Steel FE-PL2105 Air Melted Hardened and Tempered Bar for Machining De Less Than or Equal to 150 mm 1080 MPa Less Than or Equal to Rm Less T.pdf
  • ASD-STAN PREN 3519-1994 Aerospace Series Steel FE-PL2105 Air Melted Hardened and Tempered Bar for Machining De Less Than or Equal to 150 mm 880 MPa Less Than or Equal to Rm Less Th.pdf ASD-STAN PREN 3519-1994 Aerospace Series Steel FE-PL2105 Air Melted Hardened and Tempered Bar for Machining De Less Than or Equal to 150 mm 880 MPa Less Than or Equal to Rm Less Th.pdf
  • ASD-STAN PREN 3520-1994 Aerospace Series Steel FE-PL2105 Air Melted Softened Forging Stock a or D Less Than or Equal to 300 mm (Edition P 2)《航空航天系列 a或D≤300mm的FE-PL2105(41NiCrMo2)敞熔.pdf ASD-STAN PREN 3520-1994 Aerospace Series Steel FE-PL2105 Air Melted Softened Forging Stock a or D Less Than or Equal to 300 mm (Edition P 2)《航空航天系列 a或D≤300mm的FE-PL2105(41NiCrMo2)敞熔.pdf
  • 相关搜索

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

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