2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > 华中科技大学计算机上机 华中科技大学计算机学院上机复试题目.doc

华中科技大学计算机上机 华中科技大学计算机学院上机复试题目.doc

时间:2024-06-09 17:01:51

相关推荐

华中科技大学计算机上机 华中科技大学计算机学院上机复试题目.doc

华中科技大学计算机学院上机复试题目

上机考试。一般网站上公布上机环境要求是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下无法通过。华科的上机题目每年都差不多,经常考的就是排序、链表和树的操作等。建议在去复试前专门练习上机。08年的华科招收上机试题:(1)输入一个十进制数,将其先转化为八进制数,然后再输出#include

main()

{

int a = 0 ;

printf ("Please enter a decimal number:") ;

scanf ("%d",&a) ;

printf ("%d's octal number is %o\n",a,a) ;

}(2)用户输入一个文本名,编程实现输出文本中最长的一行和最短的一行。如果最长和最短的不止一行,请全部输出。#include

#include

#include

#define BUFFSIZE 1000

int main()

{

FILE *fp;

char filename[255];

printf("input file name:");

scanf("%s",filename);

if (NULL==(fp=fopen(filename,"r")))

{

printf("file open error!");

return 0;

}

char Line[BUFFSIZE][BUFFSIZE];

int i=0;

int cnt=0;

while((fgets(Line[i], BUFFSIZE, fp))&&i

{

//printf("%s",Line[i]);

i++;

cnt++;

}

char tempMax[BUFFSIZE];

char tempMin[BUFFSIZE];

strcpy(tempMax,Line[0]);

strcpy(tempMin,Line[0]);

//printf("%s\n",tempMax);

for(i=1;i

{

if(strlen(Line[i])>strlen(tempMax))

strcpy(tempMax,Line[i]);

if(strlen(Line[i])

strcpy(tempMin,Line[i]);

}

int j=-1;

printf("longest string:\n");

for(i=0;i

{

if(strlen(Line[i])==strlen(tempMax))

{

printf("%s\n",Line[i]);

}

}

printf("\n\nshortest string:\n");

for(i=0;i

{

if(strlen(Line[i])==strlen(tempMin))

{

printf("%s",Line[i]);

}

}

fclose(fp);

return 0;

}

(3)输入学生信息:学号,三门课程的成绩,学号为0时结束,将其存储在链表A中,从中找出分数大于平均分的学生,并将该学生信息按平均分降序排列存入到链表B中,最后输出链表B。#include

#include

#include

typedef struct node

{char xuehao[20];int chengji[3];float av;struct node *next;

}stud,*UerInfo;

int main()

{

UerInfo ui;

ui=(UerInfo)malloc(sizeof(stud));

UerInfo p=ui;

UerInfo q=ui;

UerInfo tempB=ui;

print

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。