硕士研究生计算机复试上机试题Word文件下载.docx

上传人:b****6 文档编号:8403045 上传时间:2023-05-11 格式:DOCX 页数:43 大小:26.09KB
下载 相关 举报
硕士研究生计算机复试上机试题Word文件下载.docx_第1页
第1页 / 共43页
硕士研究生计算机复试上机试题Word文件下载.docx_第2页
第2页 / 共43页
硕士研究生计算机复试上机试题Word文件下载.docx_第3页
第3页 / 共43页
硕士研究生计算机复试上机试题Word文件下载.docx_第4页
第4页 / 共43页
硕士研究生计算机复试上机试题Word文件下载.docx_第5页
第5页 / 共43页
硕士研究生计算机复试上机试题Word文件下载.docx_第6页
第6页 / 共43页
硕士研究生计算机复试上机试题Word文件下载.docx_第7页
第7页 / 共43页
硕士研究生计算机复试上机试题Word文件下载.docx_第8页
第8页 / 共43页
硕士研究生计算机复试上机试题Word文件下载.docx_第9页
第9页 / 共43页
硕士研究生计算机复试上机试题Word文件下载.docx_第10页
第10页 / 共43页
硕士研究生计算机复试上机试题Word文件下载.docx_第11页
第11页 / 共43页
硕士研究生计算机复试上机试题Word文件下载.docx_第12页
第12页 / 共43页
硕士研究生计算机复试上机试题Word文件下载.docx_第13页
第13页 / 共43页
硕士研究生计算机复试上机试题Word文件下载.docx_第14页
第14页 / 共43页
硕士研究生计算机复试上机试题Word文件下载.docx_第15页
第15页 / 共43页
硕士研究生计算机复试上机试题Word文件下载.docx_第16页
第16页 / 共43页
硕士研究生计算机复试上机试题Word文件下载.docx_第17页
第17页 / 共43页
硕士研究生计算机复试上机试题Word文件下载.docx_第18页
第18页 / 共43页
硕士研究生计算机复试上机试题Word文件下载.docx_第19页
第19页 / 共43页
硕士研究生计算机复试上机试题Word文件下载.docx_第20页
第20页 / 共43页
亲,该文档总共43页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

硕士研究生计算机复试上机试题Word文件下载.docx

《硕士研究生计算机复试上机试题Word文件下载.docx》由会员分享,可在线阅读,更多相关《硕士研究生计算机复试上机试题Word文件下载.docx(43页珍藏版)》请在冰点文库上搜索。

硕士研究生计算机复试上机试题Word文件下载.docx

9'

{

a[i]=x[i]-'

;

}

elseif(x[i]>

A'

Z'

+10;

a'

z'

}

unsignedaIndex1=0,aIndex2=0,bIndex=0;

intiyu=0;

while(aIndex1<

xLen)

iyu=0;

aIndex2=aIndex1;

while(aIndex2<

a[aIndex2]+=iyu*m;

iyu=a[aIndex2]%n;

a[aIndex2]/=n;

if(aIndex2==aIndex1&

a[aIndex2]==0)

{

aIndex1++;

}

aIndex2++;

if(iyu>

=0&

iyu<

=9)

b[bIndex]=iyu+'

else

b[bIndex]=iyu-10+'

bIndex++;

b[bIndex]='

\0'

strrev(b);

printf("

%s\n"

b);

return0;

}

输入一个数组的值,求出各个值从小到大排序后的次序。

输入:

输入的第一个数为数组的长度,后面的数为数组中的值,以空格分割

输出:

各输入的值按从小到大排列的次序。

sampleinput:

4

-37512-3

output:

1321

intexist(intarr[],intlen,intelem)

{

for(inti=0;

len;

if(arr[i]==elem)

returni;

arr[len]=elem;

return-1;

intinputNum,i,j,plen,temp;

intnums[1000],num1[1000];

while(scanf("

%d"

inputNum)!

=EOF)

for(i=0,plen=0;

inputNum;

scanf("

nums[i]);

if(exist(num1,plen,nums[i])==-1)

plen++;

for(i=1;

plen;

for(j=0;

j<

plen-i;

j++)

if(num1[j]>

num1[j+1])

{

temp=num1[j];

num1[j]=num1[j+1];

num1[j+1]=temp;

}

for(i=0;

if(i!

=0)

printf("

"

);

printf("

exist(num1,plen,nums[i])+1);

printf("

\n"

/***

给定两个整数A和B,其表示形式是:

从个位开始,每三位数用逗号"

"

隔开。

现在请计算A+B的结果,并以正常形式输出。

***/

iostream>

string>

usingnamespacestd;

intcovert(stringinput)

intl=input.length();

longlongsum=0;

chartemp='

for(inti=0;

l;

temp=input[i];

if(temp>

temp<

sum=10*sum+(temp-48);

if(input[0]=='

-'

sum=-sum;

returnsum;

voidmain()

stringinputA;

stringinputB;

intA,B;

while(cin>

>

inputA>

inputB)

A=covert(inputA);

B=covert(inputB);

cout<

<

A+B<

"

对给定的字符串(只包含'

'

o'

j'

三种字符),判断他是否能AC。

是否AC的规则如下:

1.zoj能AC;

2.若字符串形式为xzojx,则也能AC,其中x可以是N个'

或者为空;

3.若azbjc能AC,则azbojac也能AC,其中a,b,c为N个'

或者为空;

注意:

仔细看可以发现z前面o的个数乘以z和j之间o的个数就是j之后的个数

boolisAllO(stringstr)

int(str.length());

if(str[i]!

returnfalse;

returntrue;

booljudge(stringinput)

intfirstZIdx=input.find("

z"

),lastJidx=input.find_last_of("

j"

),length=input.length();

stringfront=input.substr(0,firstZIdx);

stringrear=input.substr(lastJidx+1);

stringmiddle=input.substr(firstZIdx+1,lastJidx-firstZIdx-1);

if(!

isAllO(front)||!

isAllO(rear)||middle.length()==0||!

isAllO(middle)||(firstZIdx>

length-1-lastJidx)){returnfalse;

if(front==rear&

middle=="

o"

returntrue;

else

stringnewStr=input.erase(length-front.length());

newStr=newStr.erase(firstZIdx+1,1);

returnjudge(newStr);

inputA)

if(judge(inputA))cout<

Accepted\n"

elsecout<

WrongAnswer\n"

fstream>

//统计文件中的单词数目

int_tmain(intargc,_TCHAR*argv[])

//read

ifstreamifs("

zxh.txt"

ios:

:

in);

charc;

intwordNum=0;

boolisSpace=true;

while(!

ifs.eof())

c=ifs.get();

if(c=='

'

||c=='

\n'

\r'

\t'

{

if(!

isSpace)//上一个不是空白字符这一个是

{

isSpace=true;

wordNum++;

if(isSpace)//上一个是空白字符这一个不是

isSpace=false;

if(c!

c!

=-1)wordNum++;

ifs.close();

cout<

wordNum;

inta;

std:

cin>

a;

1.输入一个数列以0位结束标志,建立链式线性表,查找其中最大的数并输出删除释放节点,然后对剩余的进行排序,并输出释放节点

structnode

intdata;

node*next;

};

voidprintList(node*head)//print

node*p=head->

next;

while(p!

=NULL)

p->

data<

p=p->

endl;

node*head=newnode();

head->

next=NULL;

node*n,*p=head;

intlength=0;

c)//create

)break;

if(c<

'

||c>

cout<

输入非法字符!

return0;

n=newnode();

n->

data=c-48;

p->

next=n;

length++;

printList(head);

//findmax

intmax=0;

n=p=head;

//parent

while(p->

next!

if(p->

next->

data>

max)

max=p->

data;

n=p;

//npointtothemax'

sparent

Themaxnumis:

max<

\nAfterdeletingit,thelistis:

p=n->

n->

next=n->

free(p);

length--;

//sort

p=head;

for(inti=length;

i>

0;

i--)

p=head;

for(intj=0;

i-1;

if(p->

data)

n=p->

p->

n->

p=p->

//printandfree

while(head->

head->

p=head->

free(head);

head=p;

free(head);

intm;

cin>

m;

//输入一个数列以0位结束标志,建立二叉遍历数,并对其进行逆中序遍历,释放空间

//需要注意的是释放空间时候只用在每次递归释放root就ok不要重复释放root->

lchild和root->

rchild

structtreeNode

chardata;

treeNode*lchild,*rchild;

treeNode*createTree()

c;

if(c=='

)returnNULL;

treeNode*root=newtreeNode();

root->

data=c;

lchild=createTree();

rchild=createTree();

returnroot;

voidopposingMidTraverse(treeNode*root)

if(root==NULL)return;

if(root->

rchild!

=NULL)

opposingMidTraverse(root->

rchild);

root->

lchild!

lchild);

free(root);

treeNode*root=createTree();

opposingMidTraverse(root);

/*

第三题是输入一个ip地址串,判断是否合法

合法ip地址满足:

无非法字符(非数字字符和‘.’)

.'

之间的数字在0-255之间

不是C、D类ip,ips[0]<

224

不是专用网络ip10.0.0.0-10.255.255.255172.16.0.0-172.31.255.255192.168.0.0-192.168.255.255

不能以127开头(本地主机标示)

不能是广播ip

*/

ctype.h>

stringip;

bigWhile:

ip)

intips[4];

for(inti=0;

ip.length();

if((!

isdigit(ip[i])&

ip[i]!

))

cout<

ip地址只能是数字或者‘.’组成,您输入了非法字符吧\n"

gotobigWhile;

char*c_ip=(char*)ip.c_str(),*strptr;

strptr=strtok(c_ip,"

."

char**ips_str=(char**)malloc(sizeof(char*)*10);

inti=0;

while(strptr!

ips_str[i]=strptr;

i++;

strptr=strtok(NULL,"

if(i!

=4)

请输入合法的ipv4地址,四段哦!

gotobigWhile;

4;

ips[j]=atoi(ips_str[j]);

if(ips[j]<

0||ips[j]>

255)

ip地址字段只能是0-255的数字!

if(ips[0]==127||ips[0]>

=224)

ip地址只能是ABC类地址,而且也不能是本地回环地址啊!

if(ips[0]>

ips[0]<

127)//A类

if((ips[1]==0&

ips[2]==0&

ips[3]==0)||(ips[1]==255&

ips[2]==255&

ips[3]==255))

合法ip地址不能是本网络地址或者广播地址\n"

if(ips[0]==10)

合法ip地址不能是A类专用地址(10.0.0.0-10.255.255.255)\n"

elseif(ips[0]>

127&

=191)//B类

if((ips[2]==0&

ips[3]==0)||(ips[2]==255&

if(ips[0]==172&

ips[1]>

=16&

ips[1]<

=31)

合法ip地址不能是B类专用地址(172.16.0.0-171.31.255.255)\n"

191&

=223)//C类

if((ips[3]==0)||(ips[3]==255))

if(ips[0]==192&

ips[1]==168)

合法ip地址不能是C类专用地址(192.168.0.0-192.168.255.255)\n"

ips[2]<

ips[3]<

是合法ip地址O(∩_∩)O~\n"

第一题:

对给定的一个字符串,找出有重复的字符,并给出其位置,如:

abcaaAB12ab12

输出:

a,1;

a,4;

a,5;

a,10

b,2;

b,11

1,8;

1,12

2,9;

2,13

stringinputStr;

charcurrent;

intindex=-1,lastIndex,firstIndex;

inputStr)

inputStr.length();

current=inputStr[i];

firstIndex=inputStr.find_first_of(current);

lastIndex=inputStr.find_last_of(current);

if((firstIndex!

=lastIndex)&

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

当前位置:首页 > 医药卫生 > 基础医学

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

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