游戏工程师面试题及答案.docxVIP

  • 1
  • 0
  • 约7.13千字
  • 约 20页
  • 2026-03-20 发布于福建
  • 举报

第PAGE页共NUMPAGES页

2026年游戏工程师面试题及答案

一、编程基础(15分,共5题)

题目1(3分)

请用C++实现一个单链表结构,并完成插入和删除节点的基本操作。

答案:

cpp

structListNode{

intval;

ListNodenext;

ListNode(intx):val(x),next(nullptr){}

};

classLinkedList{

public:

ListNodehead;

LinkedList():head(nullptr){}

//插入节点

voidinsert(intval){

ListNodenewNode=newListNode(val);

if(head==nullptr){

head=newNode;

}else{

ListNodecurrent=head;

while(current-next!=nullptr){

current=current-next;

}

current-next=newNode;

}

}

//删除节点

voidremove(intval){

if(head==nullptr)return;

if(head-val==val){

ListNodetemp=head

文档评论(0)

1亿VIP精品文档

相关文档