初级程序员下午试题模拟51.doc_第1页
初级程序员下午试题模拟51.doc_第2页
初级程序员下午试题模拟51.doc_第3页
初级程序员下午试题模拟51.doc_第4页
初级程序员下午试题模拟51.doc_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

51(1)(5)” ”anflag”1“” ; SWAPabab (1)(5)C” (n) ”2.1 int strcmp(char *schar *t)”stst”; s=t”0; st” 2.1 int strcmp(char *s,char *t) while(*s *t (1) ) s+; t+; return (2) ; 2.2 nnn 2.2 #include stdio.h #define N 100 int aN N; void main()int row,col,max,min,n; scanf(%dn); for(row=0; rown; row+) for(col=0; coln; col+) scanf(%d,arow col); for (row=0; rown; row+) for (max=arow0,col=1; colri; col+) if( (3) )max=a rowcol; if( (4) ) min=max; else if( (5) ) min=max; printf(The main of max number is %dn,min); C” (n) ”3.1 ()Queue2 typedef struct DateType dataMaxSize; int front2 ,rear 2; Queue2; i=01frontireariiEnQueue (Queue2*Qint iDateType x)i“ 3.1 int EnQueue (Queue2*Q,int i,DateType x) /ix”1; ”0 if (i0 | i1) return 0 if (Q-rear i =Q-front (1) ) return 0 Q-data (2) =x; Q-reari= (3) ; return 1 3.2 BTreeEqual(BinTreeNode *T1BinTreeNode *T2)”1”0T1T2“”“ “BinTreeNode struct BinTreeNode char data; BinTreeNode *left, *right; ; data“leftright“ 3.2 int BTreeEqual(BinTreeNode* T1,BinTreeNode* T2) if (T1=NULL T2=NULL) return 1; / else if( (4) )return 0; / else if( (5) )return 1; /“” / else return 0 C” (n) ” ”“getword(char *filenamechar*word)char* strdup(char* s)s” #include stdio. h #includectype. h #include string.h #define MAXWORD 100 struct node char *word; int count; struct node *left; struct node *right; struct node *addtree(struct node *p,char *w) int cond; if (p=NULL) /*“*/ p=(struct node*) malloc(sizeof(struct node); p-word=strdup (w); p-count=1; (1) ; else if(cond=strcmp (w,p-word)=0) (2) ; else if (cond0) p-left= (3) ; else p-right= (4) ; return p; main() struct node *root; char word MAXWORD; root=NULL; filename=example .dat; while getword(filename,word)! =EOF root= (5) ; ”C+” (n) ” ”“”“ C+ #includeiostream. h #includestdio. h enum boolean False,True; class base Protected: char name 8; public : void getname() cout“:;cinname; void printname() cout“:nameendU virtual boolean isgood () =0; class student: (1) int num; public : voici getnum () cout:; cinnum; boolean isgood() return (2) ; ; class teacher: (3) int num; public : void getnum () cout; cinnum; boolean isgood() return (4) ; void main () base *p50; student*pstud; teacher*ptech; char ch; int count=0; do cunt“(t)”(S):; cinch; if(ch=s) pstud=new student; pstud-getname (); pstud-getnum(); p count+ =pstud; else if(ch=t) ptech=newteacher; ptech-getname(); ptech-getnum(); pcount+=ptech; else cout“”endl; cout“(Y/n); cinch; while(ch=Y); for (int i=0;icount;i+) if( (5) ) /“ p i-printname(); Java” (n) ” ShapeShape”PointCircleCylinder Java (1) Shape public abstract void printShapeName(); / public double area()return 0.0; public double volumn()return 0.0; class Point extends Shape private double x.y; public Point (double a, double b)x=a; y=b; public void setPoint (double a,double b)x=a;y=b; final public double getX() return x; final public double getY()return y; public void printShapeName() (2) ; class Circle extends Point private double radius; public Circle(double r, double a, double b) (3) ; radius=r0? r:0; public void setRadius (double r) radius=r0 ? r:0; public double getRadius () return radius; public double area()return 3.14259 * radius * radius; public void printshapeName () System.out.print (circle: ) ; ;class Cylinder (4) private double height; public Cylinder(double h, double r, double x, double y) super (r, x, y) ; height = h0 ? h:0; public void setHeight (double h) height = h0 ? h:0; public double area () / return (5) ; public double volumn () double r=super.getRadius () ; return 3.14159 * r * r * height; public void printShapeName () System. out .print (cylinder: ) ; ”:1 leftrightflag=1; 2 leftright-11; 3aiai+1; 4flag=1; 5 aRight-iaRight-i-1 (1)”leftrightflag=1flag=0(1)leftright flag=1”(2)”leftright-11left“aiai+1flag1(3)aiai+1(4)flag=1; right“aRight-iaRight-i-1flag1(5)”aRight-iaRight-i-11*s=*t 2*s-*p 3arowcolmax 4row=0 5maxmin 1”(1)”*s=*t“”(2)”*s-*p 2max”max”max(3)”arowcolmaxmin”n“maxmin(4)row=0; maxminmaxmin(5)maxmin1(i+1)%21-i 2 Q-reari 3 Q-reari+1)%Maxsize 4 T1= =NULL|T2=NULL 5 T1-data=T2-data BTreeEqual(T1-left, T2-left)BTreeEqual(T1-right, T2-right) ” (1)if“0010; “1101(1)”(i+1)%21-i(2)(3)“xi1(2)”Q-reari”(3)”(Q-reari+1)%Maxsize ”C”(4)(4)”T1=NULL|T2=NULL(5)”“”(5)”T1-data=T2-dataBTreeEqual(T1-leftT2-left)BTreeEqual(T1-rightT2-right)1p-left=p-right=NULL 2p-count+ 3adtree(p-leftw) 4adtree(p-right,w) 5adtree(rootword) ”“”“(1)p-left=p-right=NULL(2)p-count+;“”(3)adtree(p-leftw);“”(4)adtree(p-rightw)”(5)adtree(rootword)”1public base 2 (mum90)?True: False 3 public base 4(num3)?True:False 5 pi-isgood()=True basestudentteacher”(1)(3)”public base ”studentteacherisgood()”90(2)”(mum90)? True:False3(4)”(num3)?True:False p”“”(5)”isgood()”pi-isgood()=True1abstract class 2System.out.print(Point:) 3super(ab) 4extends Circle 52*Circle:area()+2*3.14159*Circle:getRadius()*height Java“ printShapeName()-“4ShapePointCircleCylinder()4

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论