华中科技大学计算机学院上机复试题目Word下载.docx

上传人:b****5 文档编号:19847787 上传时间:2023-01-10 格式:DOCX 页数:36 大小:26.83KB
下载 相关 举报
华中科技大学计算机学院上机复试题目Word下载.docx_第1页
第1页 / 共36页
华中科技大学计算机学院上机复试题目Word下载.docx_第2页
第2页 / 共36页
华中科技大学计算机学院上机复试题目Word下载.docx_第3页
第3页 / 共36页
华中科技大学计算机学院上机复试题目Word下载.docx_第4页
第4页 / 共36页
华中科技大学计算机学院上机复试题目Word下载.docx_第5页
第5页 / 共36页
点击查看更多>>
下载资源
资源描述

华中科技大学计算机学院上机复试题目Word下载.docx

《华中科技大学计算机学院上机复试题目Word下载.docx》由会员分享,可在线阅读,更多相关《华中科技大学计算机学院上机复试题目Word下载.docx(36页珍藏版)》请在冰豆网上搜索。

华中科技大学计算机学院上机复试题目Word下载.docx

inputfilename:

);

scanf("

%s"

filename);

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

r"

)))

{

printf("

fileopenerror!

return0;

}

charLine[BUFFSIZE][BUFFSIZE];

inti=0;

intcnt=0;

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

&

i<

BUFFSIZE)

{

//printf("

Line[i]);

i++;

cnt++;

}

chartempMax[BUFFSIZE];

chartempMin[BUFFSIZE];

strcpy(tempMax,Line[0]);

strcpy(tempMin,Line[0]);

//printf("

%s\n"

tempMax);

for(i=1;

cnt;

i++)

if(strlen(Line[i])>

strlen(tempMax))

strcpy(tempMax,Line[i]);

if(strlen(Line[i])<

strcpy(tempMin,Line[i]);

intj=-1;

longeststring:

\n"

for(i=0;

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

{

printf("

}

\n\nshorteststring:

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

fclose(fp);

return0;

(3)输入学生信息:

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

typedefstructnode

{charxuehao[20];

intchengji[3];

floatav;

structnode*next;

}stud,*UerInfo;

UerInfoui;

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

UerInfop=ui;

UerInfoq=ui;

UerInfotempB=ui;

inputstudents'

information:

while

(1)

{

input学号:

ui->

xuehao);

if(strcmp(ui->

xuehao,"

0"

)==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;

intchengji1=0;

intchengji2=0;

intchengji3=0;

while(p&

strcmp(p->

)!

=0)

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(cnt)

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

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

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

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

高于平均分的有:

while(q&

strcmp(q->

if(q->

av>

avfinal)

{

printf("

q->

%f\n"

av);

}

q=q->

\n降序排列如下:

UerInfos;

s=(UerInfo)malloc(cnt*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<

cnt-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]);

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

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

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

inti;

intj;

for(i=0;

n;

for(j=0;

j<

m;

j++)

scanf("

a[i][j]);

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

inti;

intj;

for(i=0;

b[i]=0;

c[i]=0;

d[i]=0;

sum[i]=0;

intmax=a[i][0];

intcol=0;

intr=0;

for(j=0;

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

if(max<

a[i][j])

max=a[i][j];

r=i;

col=j;

b[i]=max;

c[i]=r;

d[i]=col;

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

voiddisplayMat(inta[5][6])

5;

for(j=0;

6;

%d"

a[i][j]);

inta[5][6];

getMat(a,5,6);

intc[5],d[5],b[5],sum[5];

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

每行最大值:

for(inti=0;

第%d行:

\n最大值:

%d\n列:

%d\n和:

%d\n"

i+1,b[i],d[i],sum[i]);

结果矩阵:

displayMat(a);

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

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的矩阵并存储,把该矩阵逆置并输出。

要求:

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

voidTwoDto1D(inta[6][6],intb[36])

inti,j;

for(j=0;

b[6*i+j]=a[i][j];

voidTransposeInplace(intb[36],int&

width,int&

height)

intfrom,to,offset,step;

inti,j;

for(i=to=offset=0,step=width;

i<

width;

++i,--step,offset+=height-1){

for(j=0,from=i+offset;

j<

height;

++j,++to,from+=step){

inttemp;

temp=b[to];

b[to]=b[from];

b[from]=temp;

//b[to]=b[from];

inttemp;

temp=width;

width=height;

height=temp;

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

inti;

intj;

for(i=0;

{

scanf("

}

return0;

voiddisplay(intb[36])

36;

if(i%6==0)

b[i]);

intmain()

inta[6][6];

intb[36];

getMat(a,6,6);

TwoDto1D(a,b);

intwidth=6;

intheight=6;

TransposeInplace(b,width,height);

display(b);

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

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

命令行形式:

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

功能:

复制2.txt3.txt4.txt…的内容到1.txt中

#defineBUFFERSIZE1000

intmain(intargc,char*argv[])

if(argc<

3)

参数不足\n"

//intcnt=argc-1;

if(NULL==(fp=fopen(argv[1],"

a"

目标文件打开失败!

fprintf(fp,"

"

FILE*fpSRC;

for(i=2;

argc;

if(NULL==(fpSRC=fopen(argv[i],"

源文件打开失败!

chartemp[BUFFERSIZE+1];

while(fgets(temp,BUFFERSIZE,fpSRC))

fprintf(fp,"

temp);

fclose(fpSRC);

内容复制成功!

fclose(fp);

(2)判定一个C语言变量的命名是否正确

intcheck(char*str)

char*temp=str;

if(!

(*temp=='

_'

||(*temp>

='

a'

*temp<

z'

)||(*temp>

A'

Z'

temp++;

while(*temp!

\0'

0'

9'

temp++;

return1;

while

(1)

inputvar:

charhaha[255];

haha);

if(check(haha))

CORRECT\n"

else

WRONG\n"

(3)建立一种数据结构,可以存储任意个、任意长度的整数,利用这个数据结构,输入一串数,排序,求累加和

structnode*next;

structnode*pre;

}bigIntNode,*bigInt;

bigIntgetBigInt(char*s)

bigIntbi;

bi=(bigInt)malloc(sizeof(bigIntNode));

bi->

pre=NULL;

bigInttemp=bi;

char*p=s;

while(*p!

bi->

i=*p-‘0’;

//太浪费了吧,一个字符存储一下子

bi->

next=(bigInt)malloc(sizeof(bigIntNode));

bigIntt=bi;

bi=bi->

pre=t;

p++;

next=NULL;

returntemp;

intdisplay(bigIntbi)

bigIntp=bi;

if(p->

i)

p->

i);

while(p->

next)

p=p->

bigIntadd(bigIntbi1,bigIntbi2)

bigIntp=bi1;

bigIntq=bi2;

while(p->

while(q->

q=q->

bigIntret=(bigInt)malloc(sizeof(bigIntNode));

ret->

i=0;

intfinali=0;

intadd=0;

q)

inti=p->

i+q->

i;

intt=0;

intj=0;

if(i>

9)

j=i/10;

t=i%10;

else

j=0;

t=i;

ret->

i=t;

bigInttb=(bigInt)malloc(sizeof(bigIntNode));

tb->

i+=j;

pre=tb;

next=ret;

ret=tb;

pre;

finali=j;

if(p)

intf=0;

while(p)

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

当前位置:首页 > 高中教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1