华中科技大学计算机考研复试机试题(含代码).doc
(24页)
本资源提供全文预览,点击全文预览即可全文预览,如果喜欢文档就下载吧,查找使用更方便哦!
24.9 积分
华科历年复试机试题汇总上机考试。一般网站上公布上机环境要求是TC2.0,但实际上是可以使用VC的。这里有一点特别要大家注意:TC2.0只支持纯C代码,不支持C++风格代码。华科的计算机学生称,不管你是用VC还是TC,老师都要在TC2.0上进行验收程序,以确认你的代码是纯C。比如:p = new Node ; 的代码写法在TC2.0下是通不过的,只能写p = (Node *)malloc (sizeof (Node)) ; 。另外TC2.0不支持引用,如:Pop (Stack &s , ElemType &e)中含有“&”的引用,在TC2.0下无法通过。 华科的上机题目每年都差不多,经常考的就是排序、链表和树的操作等。建议在去复试前一定要进行专门练习上机。Note:上机时间为1个半小时,题目一般为三道题,前两道一般代码不会超过70行,最后一道会达到150~200行。上机时做题速度一定要快,不要总抓着一个不放,时间在不知不觉中过的是很快的。2010年的机试题:a、输入一个字符串,然后对每个字符进行奇校验,最后输出校验后的二进制数!(如‘3’,输出:10110011);#include #include #define max 1000int pd(char c){ int i=0; int num=0; for(i=0;i<7;i++) { if(c&(1<=0)) { s1=buff1[n1]-'0'; s2=buff2[n2]-'0'; if(s1+s2+flag>9) { 。省略部分。intf("\n"); return 0; } (7)建立二叉树,并中序遍历。#include #include typedef struct tnode{ int value; struct tnode *lchild; struct tnode *rchild;}BTreeNode,*BTree;BTree createBTree(){ int value; BTree t; scanf("%d",&value); if (value==0) /* 判断当前子树是否创建完成*/ return NULL; else { t=(BTree)malloc(sizeof(BTreeNode)); t->value=value; t->lchild=createBTree(); t->rchild=createBTree(); return t; }}void InorderBTree(BTree B) { if(B) { InorderBTree(B->lchild); printf("%d\n",B->value); InorderBTree(B->rchild); } }int main() { printf("输入整数,以结尾\n"); BTree B=createBTree(); printf("中序遍历如下:\n"); InorderBTree(B); return 0; }(8)生成一个长度为21的数组,依次存入1到21;建立一个长度为21的单向链表,将上述数组中的数字依次存入链表每个结点中;将上述链表变为单向封闭(循环)链表;从头结点开始数,将第17个结点删除,将它的下一个结点作为新的头结点;重复上述过程,直到该链表中只剩一个结点,显示该结点中存入的数字。分三个文件,一个main; 一个.h; 一个.c 文件,写函数 (1).main #include #include #include "Count 21.h" int main() { struct node * head, * current; int i; head = CreatNode(); printf("##%d##\n", head -> a); while(head -> Next != NULL) { current = head; for(i = 1; i Next; } head = current -> Next; if(head -> Next != current) //是否是只剩2个节点 { printf("Deleted the number %d\n", current -> a); DeleteNode(current); } else//只剩两个节点 { head -> Next = NULL; free(current); } } printf("The last number is %d\n", head -> a); return 0; } (2) .h file #ifndef COUNT_21_H_INCLUDED #define COUNT_21_H_INCLUDED #define NUM 21 typedef struct node{ //define the struct struct node * Next ; int a; }node; struct node * CreatNode(); //two functions void DeleteNode(struct node * current); #endif // COUNT_21_H_INCLUDED (3) .c file #include #include #include "Count 21.h" struct node * CreatNode() { int i; struct node * head = NULL, * current = NULL, * temp = NULL; for(i = 0; i a = 1; temp = head; } else { current = (struct node * )malloc(sizeof(struct node)); temp -> Next = current; temp = current; temp -> a = i + 1; } } current -> Next = head; //make it a cycle return head; } void DeleteNode(struct node * current) { struct node * temp; temp = current; while(temp -> Next != current) temp = temp -> Next; (temp -> Next) = (current -> Next); free(current); } 关 键 词: 科技大学 试题 复试 考研 计算机 代码 华中
天天文库所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
关于本文