【计算机类职业资格】程序员-16及答案解析.doc

上传人:postpastor181 文档编号:1336097 上传时间:2019-10-17 格式:DOC 页数:6 大小:32KB
下载 相关 举报
【计算机类职业资格】程序员-16及答案解析.doc_第1页
第1页 / 共6页
【计算机类职业资格】程序员-16及答案解析.doc_第2页
第2页 / 共6页
【计算机类职业资格】程序员-16及答案解析.doc_第3页
第3页 / 共6页
【计算机类职业资格】程序员-16及答案解析.doc_第4页
第4页 / 共6页
【计算机类职业资格】程序员-16及答案解析.doc_第5页
第5页 / 共6页
点击查看更多>>
资源描述

1、程序员-16 及答案解析(总分:45.00,做题时间:90 分钟)一、试题一(总题数:1,分数:15.00)1.说明 用输入/输出写一个程序,让用户输入一些姓名和电话号码。每一个姓名和号码将加在文件里。用户通过点“Done”按钮来告诉系统整个列表已输入完毕。 如果用户输入完整的列表,程序将创建一个输出文件并显示或打印出来。格式如:555,1212,Tom 123-456-7890,Peggy L.234-5678,Marc 234-5678,Ron 876-4321,Beth byte name=new byte lineLength; int i; try fos= new FileOutp

2、utStream (“phone. numbers“); catch (FileNotFoundException e) while (true) _ 1_ (“Enter a name (enter “done“ to quit)“); _ 2_ (name); if (“done“. equalsIgnoteCase (new String (name,0,0,4) break; System.err.println (“Enter the phone number“); readLine (phone); for (int i=0;phone i!=0;i+) _ 3_ ; fos.wr

3、ite (“,“); for (int i=0 _ 4_ ;i+) fos. write (name i); fos. write (“n“); fos. close(); private static void readLine (byte line ) throws IOException int i=0,b=0; while (i _ 5_ ) linei= ( byte ) 0; (分数:15.00)二、试题二(总题数:1,分数:15.00)2.说明 完成以下中序线索化二叉树的算法。 函数 Typedef int datatype; Typedef struct node Int lt

4、ag, rtag; Datatype data; *lchild,* rchild; bithptr; bithptr pre; void inthread ( p ); if inthread ( p-lchild ); if ( p-lchild=unll ) _ 1_ ; if ( P-RCHILD=NULL) p-rtag=1; if _ 2_ if _ 3_ pre-rchild=p; if ( p-1tag=1 ) _ 4_ ; INTHREAD ( P-RCHILD ); _ 5_ ; (分数:15.00)三、试题三(总题数:1,分数:15.00)3.说明 本程序求 3100 之

5、间的所有素数(质数)并统计个数;同时将这些素数从小到大依次写入顺序文件 E: dataout.txt;素数的个数显示在窗体 Form1 上。 Visual Basic 代码 Private Sub Command1_ Click ( ) Dim count as integer, flag as Boolean Dim t1 as Integer, t2 as Integer _ 1_ Count=0 For t1=3 to 100 Flag=Tree For t2=2 to Int( Sqr ( t1 ) ) If _ 2_ Then flag=False Next t2 _ 3_ coun

6、t= _ 4_ write #1, t1 End if Next t1 _ 5_ Close #1 End Sub (分数:15.00)程序员-16 答案解析(总分:45.00,做题时间:90 分钟)一、试题一(总题数:1,分数:15.00)1.说明 用输入/输出写一个程序,让用户输入一些姓名和电话号码。每一个姓名和号码将加在文件里。用户通过点“Done”按钮来告诉系统整个列表已输入完毕。 如果用户输入完整的列表,程序将创建一个输出文件并显示或打印出来。格式如:555,1212,Tom 123-456-7890,Peggy L.234-5678,Marc 234-5678,Ron 876-43

7、21,Beth byte name=new byte lineLength; int i; try fos= new FileOutputStream (“phone. numbers“); catch (FileNotFoundException e) while (true) _ 1_ (“Enter a name (enter “done“ to quit)“); _ 2_ (name); if (“done“. equalsIgnoteCase (new String (name,0,0,4) break; System.err.println (“Enter the phone nu

8、mber“); readLine (phone); for (int i=0;phone i!=0;i+) _ 3_ ; fos.write (“,“); for (int i=0 _ 4_ ;i+) fos. write (name i); fos. write (“n“); fos. close(); private static void readLine (byte line ) throws IOException int i=0,b=0; while (i _ 5_ ) linei= ( byte ) 0; (分数:15.00)解析:System. err. println rea

9、dLine fos. write(phonei) namei!=0 lineLength-1二、试题二(总题数:1,分数:15.00)2.说明 完成以下中序线索化二叉树的算法。 函数 Typedef int datatype; Typedef struct node Int ltag, rtag; Datatype data; *lchild,* rchild; bithptr; bithptr pre; void inthread ( p ); if inthread ( p-lchild ); if ( p-lchild=unll ) _ 1_ ; if ( P-RCHILD=NULL)

10、p-rtag=1; if _ 2_ if _ 3_ pre-rchild=p; if ( p-1tag=1 ) _ 4_ ; INTHREAD ( P-RCHILD ); _ 5_ ; (分数:15.00)解析:P-LTAG=0 (PRE) (PRE-RTAG=1) P-LCHILD=PRE PRE=P三、试题三(总题数:1,分数:15.00)3.说明 本程序求 3100 之间的所有素数(质数)并统计个数;同时将这些素数从小到大依次写入顺序文件 E: dataout.txt;素数的个数显示在窗体 Form1 上。 Visual Basic 代码 Private Sub Command1_ Cl

11、ick ( ) Dim count as integer, flag as Boolean Dim t1 as Integer, t2 as Integer _ 1_ Count=0 For t1=3 to 100 Flag=Tree For t2=2 to Int( Sqr ( t1 ) ) If _ 2_ Then flag=False Next t2 _ 3_ count= _ 4_ write #1, t1 End if Next t1 _ 5_ Close #1 End Sub (分数:15.00)解析:Open “e:dataout.txt“ For Output as #1 t1 mod t2=0 If t2Int (sqr(t1)Then count +1 Form1.Print “素数个数“; count

展开阅读全文
相关资源
猜你喜欢
  • GOST 19047-1980 Hexagon throw-away (indexable) carbide cutting inserts with 80 included angle and cylindrical holes Design and dimensions《可转位的多面体带孔和80角的六棱形硬质合金切削刀片 结构及尺寸》.pdf GOST 19047-1980 Hexagon throw-away (indexable) carbide cutting inserts with 80 included angle and cylindrical holes Design and dimensions《可转位的多面体带孔和80角的六棱形硬质合金切削刀片 结构及尺寸》.pdf
  • GOST 19048-1980 Hexagon throw-away (indexable) carbide cutting inserts with 80 included angle with cylindrical holes and chip-breaking flutes Design and dimensions《可转位的多面体成80角的带孔和切.pdf GOST 19048-1980 Hexagon throw-away (indexable) carbide cutting inserts with 80 included angle with cylindrical holes and chip-breaking flutes Design and dimensions《可转位的多面体成80角的带孔和切.pdf
  • GOST 19049-1980 Square throw-away (indexable) carbide cutting inserts Design and dimensions《可转位的正方形多面硬质合金切削刀片 结构及尺寸》.pdf GOST 19049-1980 Square throw-away (indexable) carbide cutting inserts Design and dimensions《可转位的正方形多面硬质合金切削刀片 结构及尺寸》.pdf
  • GOST 19050-1980 Square throw-away (indexable) carbide cutting inserts with 11 end-clearance angle Design and dimensions《可转位的带11后角的正方形多面硬质合金切削刀片 结构及尺寸》.pdf GOST 19050-1980 Square throw-away (indexable) carbide cutting inserts with 11 end-clearance angle Design and dimensions《可转位的带11后角的正方形多面硬质合金切削刀片 结构及尺寸》.pdf
  • GOST 19051-1980 Square throw-away (indexable) carbide cutting inserts with cylindrical holes Design and dimensions《可转位的带孔多面的正方形硬质合金切削刀片 结构及尺寸》.pdf GOST 19051-1980 Square throw-away (indexable) carbide cutting inserts with cylindrical holes Design and dimensions《可转位的带孔多面的正方形硬质合金切削刀片 结构及尺寸》.pdf
  • GOST 19052-1980 Square throw-away (indexable) carbide inserts with cylindrical holes and chip-breaking flutes on one face only Design and dimensions《可转位的带孔多面和单侧有切屑槽的正方形硬质合金切削刀片 结构及.pdf GOST 19052-1980 Square throw-away (indexable) carbide inserts with cylindrical holes and chip-breaking flutes on one face only Design and dimensions《可转位的带孔多面和单侧有切屑槽的正方形硬质合金切削刀片 结构及.pdf
  • GOST 19053-1980 Square throw-away (indexable) carbide cutting inserts with cylindrical holes and secondary edges at cutting points Design and dimensions《可转位的带孔和顶端有斜边的正方形多面硬质合金切削刀片 .pdf GOST 19053-1980 Square throw-away (indexable) carbide cutting inserts with cylindrical holes and secondary edges at cutting points Design and dimensions《可转位的带孔和顶端有斜边的正方形多面硬质合金切削刀片 .pdf
  • GOST 19056-1980 Rhombic throw-away (indexable) carbide cutting inserts with 80 included angle Design and dimensions《可转位的80菱形的多面的硬质合金切削刀片 结构及尺寸》.pdf GOST 19056-1980 Rhombic throw-away (indexable) carbide cutting inserts with 80 included angle Design and dimensions《可转位的80菱形的多面的硬质合金切削刀片 结构及尺寸》.pdf
  • GOST 19057-1980 Rhombic throw-away (indexable) carbide cutting inserts with 80 included angle and cylindrical holes Design and dimensions《可转位的带孔的80菱形多面的硬质合金切削刀片 结构及尺寸》.pdf GOST 19057-1980 Rhombic throw-away (indexable) carbide cutting inserts with 80 included angle and cylindrical holes Design and dimensions《可转位的带孔的80菱形多面的硬质合金切削刀片 结构及尺寸》.pdf
  • 相关搜索

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

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