华中科技大学计算机考研复试机试题含代码Word格式.docx

上传人:b****1 文档编号:1546513 上传时间:2023-04-30 格式:DOCX 页数:52 大小:48.28KB
下载 相关 举报
华中科技大学计算机考研复试机试题含代码Word格式.docx_第1页
第1页 / 共52页
华中科技大学计算机考研复试机试题含代码Word格式.docx_第2页
第2页 / 共52页
华中科技大学计算机考研复试机试题含代码Word格式.docx_第3页
第3页 / 共52页
华中科技大学计算机考研复试机试题含代码Word格式.docx_第4页
第4页 / 共52页
华中科技大学计算机考研复试机试题含代码Word格式.docx_第5页
第5页 / 共52页
华中科技大学计算机考研复试机试题含代码Word格式.docx_第6页
第6页 / 共52页
华中科技大学计算机考研复试机试题含代码Word格式.docx_第7页
第7页 / 共52页
华中科技大学计算机考研复试机试题含代码Word格式.docx_第8页
第8页 / 共52页
华中科技大学计算机考研复试机试题含代码Word格式.docx_第9页
第9页 / 共52页
华中科技大学计算机考研复试机试题含代码Word格式.docx_第10页
第10页 / 共52页
华中科技大学计算机考研复试机试题含代码Word格式.docx_第11页
第11页 / 共52页
华中科技大学计算机考研复试机试题含代码Word格式.docx_第12页
第12页 / 共52页
华中科技大学计算机考研复试机试题含代码Word格式.docx_第13页
第13页 / 共52页
华中科技大学计算机考研复试机试题含代码Word格式.docx_第14页
第14页 / 共52页
华中科技大学计算机考研复试机试题含代码Word格式.docx_第15页
第15页 / 共52页
华中科技大学计算机考研复试机试题含代码Word格式.docx_第16页
第16页 / 共52页
华中科技大学计算机考研复试机试题含代码Word格式.docx_第17页
第17页 / 共52页
华中科技大学计算机考研复试机试题含代码Word格式.docx_第18页
第18页 / 共52页
华中科技大学计算机考研复试机试题含代码Word格式.docx_第19页
第19页 / 共52页
华中科技大学计算机考研复试机试题含代码Word格式.docx_第20页
第20页 / 共52页
亲,该文档总共52页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

华中科技大学计算机考研复试机试题含代码Word格式.docx

《华中科技大学计算机考研复试机试题含代码Word格式.docx》由会员分享,可在线阅读,更多相关《华中科技大学计算机考研复试机试题含代码Word格式.docx(52页珍藏版)》请在冰点文库上搜索。

华中科技大学计算机考研复试机试题含代码Word格式.docx

else

return0;

}

voidmain()

chara[max];

scanf("

%s"

a);

inti,j;

intlen=strlen(a);

len;

if(pd(a[i]))

{

a[i]=a[i]|(1<

7);

}

for(j=7;

j>

=0;

j--)

if(a[i]&

j))

printf("

1"

);

else

0"

printf("

\n"

b、设计8个任务函数task0〔〕-task7〔〕只输出一句话:

如task0〔〕输出“task0iscalled!

〞;

设计一个调度函数schedule〔〕输入一个字符串如"

012345"

然后返回一个函数指针数组和字符串的长度作为执行函数execute〔〕的参数进展调度任务函数。

主函数只有调度函数。

〔这个题难道很多同学因为很多同学不知道函数指针数组怎么用啊!

#include<

stdlib.h>

typedefvoid(*ptask)();

//8个任务函数;

voidtask0(){

printf("

task0iscalled!

voidtask1(){

task1iscalled!

voidtask2(){

task2iscalled!

voidtask3(){

task3iscalled!

voidtask4(){

task4iscalled!

voidtask5(){

task5iscalled!

voidtask6(){

task6iscalled!

voidtask7(){

task7iscalled!

ptaskfun[9]={task0,task1,task2,task3,task4,task5,task6,task7,};

voidexecute(ptask*fun,intlen){//执行函数

for(inti=0;

i++){

ptaskpfun=fun[i];

pfun();

voidschedule(){//调度函数;

ptaskfun[100];

//定义函数指针数组;

intlen;

//字符串长度;

chars[1000];

请输入字符串:

s);

len=strlen(s);

inttemp;

temp=s[i]-'

0'

;

if(temp==0)fun[i]=task0;

elseif(temp==1)fun[i]=task1;

elseif(temp==2)fun[i]=task2;

elseif(temp==3)fun[i]=task3;

elseif(temp==4)fun[i]=task4;

elseif(temp==5)fun[i]=task5;

elseif(temp==6)fun[i]=task6;

elseif(temp==7)fun[i]=task7;

execute(fun,len);

intmain(){

schedule();

system("

pause"

c、实现一个加法器,保证两个加数是任意长的整数。

〔这个题的加数由于是任意长所以把它声明成什么类型〔long、int〕的都是不对的,要用到构造体〕。

〔所以这应该是个串行加法器〕

voidadd(charbuff1[max],charbuff2[max],intlen1,intlen2)

intnum[max];

ints1,s2,flag=0,i;

max;

num[i]=0;

intn1=len1-1,n2=len2-1;

intk=max-1;

while((n1>

=0)&

&

(n2>

=0))

s1=buff1[n1]-'

s2=buff2[n2]-'

if(s1+s2+flag>

9)

num[k]=(s1+s2+flag)%10;

flag=1;

else

num[k]=(s1+s2+flag)%10;

flag=0;

n1--;

n2--;

k--;

if(n1>

=0)

while(n1>

s1=buff1[n1]-'

if(s1+flag>

{

num[k]=(s1+flag)%10;

flag=1;

}

flag=0;

n1--;

k--;

if(n2>

while(n2>

s1=buff2[n1]-'

n2--;

if(flag)

num[k]=1;

for(i=k+1;

=max-1;

printf("

%d"

num[i]);

charbuff1[max];

charbuff2[max];

intlen1,len2;

buff1);

buff2);

len1=strlen(buff1);

len2=strlen(buff2);

add(buff1,buff2,len1,len2);

==?

08年的华科招收研究生上机试题:

(1)输入一个十进制数,将其先转化为八进制数,然后再输出

main()

{

inta=0;

printf("

Pleaseenteradecimalnumber:

"

);

scanf("

&

a);

%d'

soctalnumberis%o\n"

a,a);

}

(2)用户输入一个文本名,编程实现输出文本中最长的一行和最短的一行。

如果最长和最短的不止一行,请全部输出。

#defineBUFFSIZE1000

intmain(){

FILE*fp;

charfilename[255];

Pleaseinputthenameofthefile:

filename);

if((fp=fopen(filename,"

r"

))==NULL){

Fileopenerror!

}

charLine[BUFFSIZE][BUFFSIZE];

inti,t;

i=0;

t=0;

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

BUFFSIZE)

{

i++;

t++;

chartempMax[BUFFSIZE];

chartempMin[BUFFSIZE];

strcpy(tempMax,Line[0]);

strcpy(tempMin,Line[0]);

for(i=1;

t;

i++){

if(strlen(Line[i])>

strlen(tempMax))

strcpy(tempMax,Line[i]);

if(strlen(Line[i])<

strlen(tempMin))

strcpy(tempMin,Line[i]);

Thelongeststring:

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

%s\n"

Line[i]);

Theshorteststring:

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

//system("

}

 

本文来自CSDN博客,请标明出处:

(3)输入学生信息:

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

typedefstructnode

{charxuehao[20];

intchengji[3];

floatav;

structnode*next;

}stud,*UerInfo;

intmain()

UerInfoui;

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

UerInfop=ui;

UerInfoq=ui;

UerInfotempB=ui;

inputstudents'

information:

intt=0;

while

(1)

input学号:

ui->

xuehao);

if(strcmp(ui->

xuehao,"

)==0)

break;

input成绩:

scanf("

ui->

chengji[0]);

chengji[1]);

chengji[2]);

ui->

av=((ui->

chengji[0]+ui->

chengji[1]+ui->

chengji[2])/3);

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

ui=ui->

next;

t++;

intchengji1=0;

intchengji2=0;

intchengji3=0;

while(p&

strcmp(p->

)!

chengji1+=p->

chengji[0];

chengji2+=p->

chengji[1];

chengji3+=p->

chengji[2];

p=p->

floatchengji1av=0.0;

floatchengji2av=0.0;

floatchengji3av=0.0;

floatavfinal=0.0;

if(t)

chengji1av=(float)chengji1/(float)t;

chengji2av=(float)chengji2/(float)t;

chengji3av=(float)chengji3/(float)t;

avfinal=(chengji1av+chengji2av+chengji3av)/3;

高于平均分的有:

while(q&

strcmp(q->

if(q->

av>

avfinal)

{

q->

%f\n"

av);

}

q=q->

\n降序排列如下:

UerInfos;

s=(UerInfo)malloc(t*sizeof(stud));

intk=0;

UerInfotemp=tempB;

while(tempB&

strcmp(tempB->

s[k].av=tempB->

av;

s[k].chengji[0]=tempB->

s[k].chengji[1]=tempB->

s[k].chengji[2]=tempB->

strcpy(s[k].xuehao,tempB->

tempB=tempB->

k++;

intl,m;

studtemps;

for(l=0;

l<

t-1;

l++)

for(m=l+1;

m<

m++)

if(s[l].av<

s[m].av)

temps.chengji[0]=s[l].chengji[0];

temps.chengji[1]=s[l].chengji[1];

temps.chengji[2]=s[l].chengji[2];

strcpy(temps.xuehao,s[l].xuehao);

s[l].chengji[0]=s[m].chengji[0];

s[l].chengji[1]=s[m].chengji[1];

s[l].chengji[2]=s[m].chengji[2];

strcpy(s[l].xuehao,s[m].xuehao);

s[m].chengji[0]=temps.chengji[0];

s[m].chengji[1]=temps.chengji[1];

s[m].chengji[2]=temps.chengji[2];

strcpy(s[m].xuehao,temps.xuehao);

for(inti=0;

学号:

s[i].xuehao);

成绩:

s[i].chengji[0]);

s[i].chengji[1]);

s[i].chengji[2]);

return0;

07年的华科招收研究生上机试题

一、编写一个程序输入一个5X6的矩阵存储并输出,并且求出每行的最大值和每行的总和要求把每行总和放入每行最大值的位置,最后把结果矩阵,每行最大值及其原下标及其总和输出。

我的代码:

intgetMat(inta[5][6],intn,intm){

n;

for(j=0;

j<

m;

j++)

a[i][j]);

intgetMax(inta[5][6],intn,intm,intb[5],intc[5],intd[5],intsum[5]){

b[i]=0;

c[i]=0;

d[0]=0;

sum[i]=0;

intr,col;

intmax=a[i][0];

sum[i]=a[i][0];

for(j=1;

j++){

if(max<

a[i][j])max=a[i][j];

r=i;

col=j;

sum[i]+=a[i][j];

b[i]=max;

c[i]=r;

d[i]=col;

a[c[i]][d[i]]=sum[i];

voiddisplay(inta[5][6]){

5;

6;

%d"

a[i][j]);

inta[5][6];

getMat(a,5,6);

intb[5],c[5],d[5],sum[5];

getMax(a,5,6,b,c,d,sum);

display(a);

每一行最大值为:

inti;

第%d行:

%d,其下标:

(%d,%d)\n"

i,b[i],c[i],d[i]);

每一行的总和为:

第%d行:

%d\n"

i,sum[i]);

二、编写程序判断输入的任意字符,任意长度的字符串是否回文(顺读,逆读均一样),最后输出原字符串和判断结果。

voidmain()

intbIsSame=1;

//是否一样的标志

inta=0,b;

charf[255];

f);

//读入字符串

b=strlen(f)-1;

//获得最后一个字符的序号〔字符串总长度减〕

b/2;

i++)//循环,从到字符串中间的字符

{

if(f[a++]!

=f[b--])//首尾比拟是否一样字符

{

bIsSame=0;

//有不同的就把标志置,并跳出循环

}

}

if(bIsSame)//一样就输出Y

printf("

Y"

else//不同就输出N

N"

getchar();

//按任意键退出

三、输入一个6X6的矩阵并存储,把该矩阵逆置并输出。

要求:

不得使用任何数组(就地逆置)。

inta[6][6];

请输入矩阵各元素的值【行序优先】:

inti,j,temp;

输入的矩阵:

%3d"

=i;

temp=a[j][i];

a[j][i]=a[i][j];

a[i][j]=temp;

逆置的矩阵:

数据测试:

06年的华科研究生复试上机试题:

(1)采用命令行方式复制任意多个文件容到一个文件中,如下所示:

命令行形式:

mycopy1.txt2.txt3.txt4.txt...

功能:

复制2.

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 幼儿教育 > 幼儿读物

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2