Aonesoft校园招聘笔试

31 篇文章 0 订阅
16 篇文章 0 订阅

1假定int整形指针p所指对象的值为25p+1所指对象的值为46,执行(*p++后,p所指对象的值为

答:26

int *p;
int a[2] = {25,46};
p = a;
cout<<*p<<endl;
return 0;

2、某人上楼梯,1步可以跨一个台阶或2个台阶,这个楼梯共有10个台阶,从地面到最上层共有多少种不同跨法?

答案:89

只一次两个台阶 c(1/9)=9

2次两个台阶 有c(2/8)=28

3次两个台阶 有C(3/7)=35

4次两个台阶 C(4/6)=15

5次两个台阶 1

0次两个台阶 1

 

3、下列说明中 const char *ptrptr应该是()

A 指向字符常量的指针;

B 指向字符的常量指针;

C 指向字符串常量的指针;

D 指向字符串的常量指针;

答案:A C

 

4、对使用关键字new所开辟的动态存储空间,释放时必须使用 delete

答:C++程序中由new分配的动态内存空间必须通过delete释放。

 

5、单链表逆序(三种方法)

public class LinkedList {

    class Node {
        private Node next;
        private Object data;

        public Node() {
            super();
        }

        public Node(Object data, Node next) {
            this.data = data;
            this.next = next;
        }

        public Node getNext() {
            return next;
        }

        public void setNext(Node next) {
            this.next = next;
        }

        public Object getData() {
            return data;
        }

        public void setData(Object data) {
            this.data = data;
        }
    }

    private Node head;

    public Node first() {
        return head.next;
    }

    public Node tail() {
        Node temp = head;
        while (temp.next != null)
            temp = temp.next;
        return temp;
    }

    public Node head() {
        return head;
    }

    public LinkedList() {
        head = new Node(null, null);
    }

    public boolean addStack(Object data, Node head) {
        boolean flag = false;
        Node node = new Node(data, null);
        if (!flag) {
            node.next = head.next;
            head.next = node;
            flag = true;
        }
        return flag;
    }

    public boolean addQueue(Object data, Node head) {
        Node temp = head;
        while (temp.next != null)
            temp = temp.next;
        boolean flag = false;
        Node node = new Node(data, null);
        if (!flag) {
            temp.next = node;
            flag = true;
        }
        return flag;
    }

    public void print(Node head) {
        Node temp = head;
        while (temp.next != null) {
            System.out.println("list node data :" + temp.data);
            temp = temp.next;
        }
        System.out.println("list node data :" + temp.data);
    }

    public void addQueue() {

    }
//直接头结点插入
    public LinkedList invertedList(Node head) {
        LinkedList newList = new LinkedList();
        Node temp = head;
        while (temp.next != null) {
            addStack(temp.data, newList.head);
            temp = temp.next;
        }
        addStack(temp.data, newList.head);
        return newList;
    }

    public int length() {
        Node temp = head;
        int i = 0;
        while (temp.next != null) {
            i++;
            temp = temp.next;
        }
        return i;
    }
//交换两个对应的数据来实现,链表逆序
    public void invertedListExchange(Node head) {
        Node tempStart = head;
        Object old = null;
        Node tempEnd = null;
        int halfLen = this.length() / 2;
        for (int i = 0; i < halfLen; i++) {

            tempEnd = tempStart;

            if (i == 0) {
                tempEnd = this.tail();
            }

            while (i != 0 && tempEnd.next.data != old)
                tempEnd = tempEnd.next;
            System.out.println(tempStart.data);
            Object tt = tempStart.data;
            tempStart.data = tempEnd.data;
            tempEnd.data = tt;
            old = tempEnd.data;

            tempStart = tempStart.next;
        }
    }
//利用栈的性质来实现
    public LinkedList invertedListByStack(Node head) {
        Deque<Object> stack = new java.util.LinkedList<Object>();
        Node temp = head;
        while (temp.next != null) {
            stack.push(temp.data);
            temp = temp.next;
        }
        stack.push(temp.data);
        LinkedList newList = new LinkedList();
        Node node = newList.head;
        while (!stack.isEmpty()) {
            addQueue(stack.pop(), node);
        }
        return newList;
    }
}

6TCPUDP

TCP:(Transmission Control Protocol 传输控制协议)是一种面向连接的、可靠的、基于字节流的传输层通信协议。

UDP:(User Datagram Protocol用户数据报协议)是OSIOpen System Interconnection,开放式系统互联) 参考模型中一种无连接的传输层协议,提供面向事务的简单不可靠信息传送服务。

区别: 1.基于连接与无连接

2.TCP要求系统资源较多,UDP较少; 

3.UDP程序结构较简单 

4.流模式(TCP)与数据报模式(UDP); 

5.TCP保证数据正确性,UDP可能丢包 

6.TCP保证数据顺序,UDP不保证

差别

TCP

UDP

是否连接

面向连接

面向非连接

传输可靠性

可靠

不可靠

应用场合

传输大量数据

少量数据

速度


7、分别给出 BOOLintfloat,指针变量 与“零值”,比较的 if 语句(假设变量名为 var

答:

BOOL 型变量:if(!var)

int 型变量: if(var==0)

float 型变量:

const float EPSINON = 0.00001;

if ((x >= - EPSINON) && (x <= EPSINON)

   指针变量:  if(var==NULL)


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值