1 / 12
文档名称:

(招聘面试)JEE 招聘试题.pdf

格式:pdf   大小:629KB   页数:12页
下载后只包含 1 个 PDF 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

(招聘面试)JEE 招聘试题.pdf

上传人:三角文案 2021/12/18 文件大小:629 KB

下载得到文件列表

(招聘面试)JEE 招聘试题.pdf

文档介绍

文档介绍:(招聘面试)JEE+招聘试题
网龙笔试题:
1、实现链表的创建,删除和逆序等。
#include<iostream>
#include<>
usingnamespacestd;
typedefstructstu
{
intdata;
structstu*next;
}node,list;
node*creatlist(intn)
{
node*h,*p,*s;
h=newnode;
h->next=NULL;
p=h;
cout<<“pleaseinput”<<n<<”numbers.”;
for(inti=0;i<n;i++)
{
s=newnode;
cin>>s->data;
s->next=NULL;
p->next=s;
p=s;
}
returnh;
}
voiddeletelist(node*s,inta)
{
node*p;
while(s->data!=a)
{
p=s;
s=s->next;
}
if(s==NULL)
{
cout<<“noa”;
}
else
{
p->next=s->next;
deletes;
}
}
voiddisplay(node*h)
{
h=h->next;
while(h!=NULL)
{
cout<<h->data<<ends;
h=h->next;
}
cout<<endl;
}
node*reverse(node*h)
{
node*p,*q,*s;
p=h->next;
q=p->next;
while(q->next!=NULL)
{
s=q->next;
q->next=p;
p=q;
q=s;
}
q->next=p;
h->next->next=NULL;
h->next=q;
returnh;
}
intmain()
{
intn;
node*h;
cout<<“pleaseinputthenumber:”;
cin>>n;
h=creatlist(n);
display(h);
cout<<“delete?”;
cin>>n;
deletelist(h,n);
display(h);
h=reverse(h);
display(h);
return0;
}
2、字符串逆序
输入文件是 ,内容例如如下:
hello,everyone.
mynameisshen,he.
ni,ne?
则倒序之后为:
,
,isnamemy
ne?ni,
源程序,自己实现的,算法是别人的。呵呵
#include<iostream>
#include<fstream>
#include<vector>
#include<cstring>
#include<string>
usingnamespacestd;
intmain()
{
ifstreaminFile;
ofstreamoutFile;
char*fName;
string::size_typeb,e;
charch;
stringline;
vector<string>svec;
(””);
while(getline(inFile,line))//先获取每壹行字符,且存入容器中
{
(line);
}
();
(””);
vector<string>::iteratoriter=();
while(iter!=())
{
b=0;
e=(*iter).size()–1;
while(b<e)//将该行字符整体翻转
{
ch=(*iter)[b];
(*iter)[b]=(*iter)[e];
(*iter)[e]=ch;
b++;
e–;
}
b=0;
e=0;
string::size_typei=0;
while((*iter)[i])
{
if((*iter)[i]!=‘‘)//找到壹行的壹个单词
{
b=i;
while((*iter)[i]!=‘‘&&(*iter)[i])
i++;
i–;
e=i;
}
while(b<e)//将这个单词翻转
{
ch=(*iter)[b];
(*iter)[b]=(*iter)[e];
(*iter)[e]=ch;
b++;
e–;
}