MoonChasing


  • 首页

  • 标签

  • 分类

  • 归档

  • 相册

  • 说说

  • 关于

  • 搜索

C++后台开发面试一些题目(只列举,无答案)

发表于 2019-09-03 | 更新于: 2019-09-05 | 阅读次数:
字数统计: 43 | 阅读时长 ≈ 1
  • 内核态、用户态区别,如何进入内核态
  • 为什么使用 B+ 树作为索引的数据结构。
  • extern “C”
  • 自由存储区和堆的区别

腾讯后台开发面经

发表于 2019-08-24 | 更新于: 2020-03-08 | 分类于 面经 | 阅读次数:
字数统计: 2,465 | 阅读时长 ≈ 9

请带着批判的眼光看这篇文章。或许我的一些答案是不对的。如果您发现了错误,烦请指出。

  1. C++对象模型

    这个要重点掌握, 要明白类里有什么,每个类的对象里又有什么。尤其是对虚函数表的了解。这块知识较多,不在这篇文章中详述。网上有着很多优秀的博客来介绍。

    https://coolshell.cn/articles/12176.html

    https://www.jianshu.com/p/9fb37bb3094f

  2. C++多态机制的实现原理

    主要就是上面问题中的虚函数表。

  3. 如果一个类的指针为 nullptr ,那么调用他的成员函数会不会出错。出错的话是在哪一阶段出错。

    也是对C++内存模型的一个考察以及动态绑定静态绑定。每个类的成员函数都在.text代码段,静态绑定的时候如果成员函数不访问成员变量的话那么这个函数不会出问题。如果说是虚函数或这个函数访问了成员变量,那么就会出错。虚函数出错是因为其动态绑定,因为是 nullptr, 无法确定其虚函数表。

    阅读全文 »

C++动态绑定与静态绑定

发表于 2019-08-24 | 更新于: 2019-08-24 | 分类于 C++ | 阅读次数:
字数统计: 645 | 阅读时长 ≈ 2

今天做题的时候遇到这样一个问题。

以下程序片段输出内容为:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Demo {
public:
Demo():count(0) {}
~Demo() {}

void say(const std::string&msg) {
fprintf(stderr,"%s\n", msg.c_str());
}
private:
int count;
};

int main(int argc, char **argv) {
Demo* v = NULL;
v->say("hello world");
}

阅读全文 »

Have fun with unix

发表于 2019-07-21 | 更新于: 2019-07-21 | 阅读次数:
字数统计: 462 | 阅读时长 ≈ 2

突然想起小伙伴前段时间给我看的一段神仙代码。实在特有诱惑力了。。当时女票喊我吃饭我都在看这段代码,话不多说,放码过来。

1
printf(&unix["\021%six\012\0"],(unix)["have"]+"fun"-0x60);

要解开这道题,我们首先要知道下面几点。

  • a[3] == 3[a]
    转换为指针角度看, a[3] = *(a+3) = *(3+a) = 3[a]
  • "abcdefg"[3]这种表示相当于 char str[]="abcdefg"; str[3]
  • 知道了上面那点后,我的目光就聚焦在 unix 上,我感觉它应该是一个数字,一开始以为它是个变量,但代码中没有描述,我问小伙伴这是不是全量代码,小伙伴说文章里没有看到其他的。。于是我就开始猜他的值,一开始猜的3,是因为忘记了字符串中“\0xx”的意义,把他们当成了3个字符来看。其实它们是一个字符的,这种格式表示八进制的ASCII码。然后猜 unix 值为1,后面才晓得 unix 是个宏定义, #define unix 1,这样,我们可以将上面的题目转换成较易看懂的。
1
printf( &("\021%six\012\0"[1]), "have"[1]+"fun"-0x60);

众所周知, printf()的第一个参数为字符串,或者说字符串的起始地址,我们分析后可知为%six\012\0, '%s'表示一个字符串,故我们看第 2 个参数, have[1] 也便是 'a','a'-0x60 = 97 - 96 = 1, "fun"+1 也便是字符串 "un" 的起始地址,\012 = 10, 对应 ASCII 码也便是\n。

所以这段代码其实是 printf("unix\n"); 。

unix

很棒很惊艳的代码。

阅读全文 »

Linux crontab

发表于 2019-07-21 | 更新于: 2019-07-21 | 阅读次数:
字数统计: 46 | 阅读时长 ≈ 1

***** /usr/local/run.sh 中5个*分别代表什么
答案:分钟 小时 日 月 星期几

牛客用户 进击的渣渣兔 的答案:

吃货速记:分食日月粥

Educational Codeforces Round 68 D 1-2-K Game

发表于 2019-07-21 | 更新于: 2019-07-21 | 阅读次数:
字数统计: 329 | 阅读时长 ≈ 2

Problem

time limit per test : 2 seconds
memory limit per test : 256 megabytes
input : standard input
output : standard output

Description

Alice and Bob play a game. There is a paper strip which is divided into n + 1 cells numbered from left to right starting from 0. There is a chip placed in the n-th cell (the last one).

Players take turns, Alice is first. Each player during his or her turn has to move the chip 1, 2 or k cells to the left (so, if the chip is currently in the cell i, the player can move it into cell i - 1, i - 2 or i - k). The chip should not leave the borders of the paper strip: it is impossible, for example, to move it k cells to the left if the current cell has number i < k. The player who can’t make a move loses the game.

Who wins if both participants play optimally?

Alice and Bob would like to play several games, so you should determine the winner in each game.

Input

The first line contains the single integer T (1 ≤ T ≤ 100) — the number of games. Next T lines contain one game per line. All games are independent.

Each of the next T lines contains two integers n and k (0 ≤ n ≤ 109, 3 ≤ k ≤ 109) — the length of the strip and the constant denoting the third move, respectively.

Output

For each game, print Alice if Alice wins this game and Bob otherwise.

Example

input

1
2
3
4
5
4
0 3
3 3
3 4
4 4

output

1
2
3
4
Bob
Alice
Bob
Alice

Solution

Idea

打表找规律,存在循环。

发现若 k 不为 3 的倍数,则循环节长度为3 。若 k 为 3 的倍数, 循环节长度为 k+1, 循环节内也有一定的规律。

Educational Codeforces Round 68 B Yet Another Crosses Problem

发表于 2019-07-21 | 更新于: 2019-07-21 | 阅读次数:
字数统计: 960 | 阅读时长 ≈ 6

Problem

time limit per test : 2 seconds
memory limit per test : 256 megabytes
input : standard input
output : standard output

Description

You are given a picture consisting of $nn$ rows and $m$ columns. Rows are numbered from $1$ to $n$ from the top to the bottom, columns are numbered from $1$ to $m$ from the left to the right. Each cell is painted either black or white.

You think that this picture is not interesting enough. You consider a picture to be interesting if there is at least one cross in it. A cross is represented by a pair of numbers $x$ and $y$ , where $1≤x≤n$ and $1≤y≤m$, such that all cells in row $x$ and all cells in column $y$ are painted black.

For examples, each of these pictures contain crosses:

img

The fourth picture contains 4 crosses: at $(1,3)$ , (1,5)(1,5), $(3,3)$ and $(3,5)$ .

Following images don’t contain crosses:

img

You have a brush and a can of black paint, so you can make this picture interesting. Each minute you may choose a white cell and paint it black.

What is the minimum number of minutes you have to spend so the resulting picture contains at least one cross?

You are also asked to answer multiple independent queries.

阅读全文 »

Linux源码学习——offsetof与container_of宏

发表于 2019-07-18 | 更新于: 2019-07-18 | 分类于 Linux , Linux源码学习 | 阅读次数:
字数统计: 55 | 阅读时长 ≈ 1
Linux内核源码果真精髓,相见恨晚。

offsetof 宏定义如下

1
#define offsetof(type, member) (size_t)&(((type*)0)->member)

container_of 宏定义如下

1
2
3
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})

AI复习

发表于 2019-06-28 | 更新于: 2019-07-21 | 阅读次数:
字数统计: 545 | 阅读时长 ≈ 2

基本概念:

1、 人工智能有哪几个主要学派?各自的特点是什么?

2、 人工智能有哪些主要研究和应用领域?

3、什么是产生式系统?产生式推理的基本结构由哪几部分组成?

通常人们把利用产生式知识表示方法所进行的推理称为产生式推理,把由此所产生的系统称为产生式系统。

综合数据库、规则库、控制系统

阅读全文 »

市场营销复习

发表于 2019-06-24 | 更新于: 2019-07-21 | 阅读次数:
字数统计: 6,364 | 阅读时长 ≈ 22

导论

  1. 市场和市场营销定义

    从市场营销的角度看,市场就是商品交换关系的总和

    营销学中的市场:指的是具有特定的需求或欲望,而且愿意并能够通过交换来满足这种需要和欲望的全部潜在顾客。

    一般意义的市场:是商品交易的场所,是显在和潜在买主的结合体,是买卖关系的总和。

    营销是通过创造和交换产品及价值,从而使个人或组织满足欲望和需要的社会和管理过程。

    阅读全文 »
1234…13
之伊丶

之伊丶

每从细笔惊新悟,重向高山愧旧琴。

129 日志
42 分类
88 标签
QQ 知乎 GitHub StackOverflow
(ฅ´ω`ฅ)戳一戳
  • bin神
  • 每天%bin神
  • coswindy
  • CFZhao
  • 张老板
  • Kehuaiiiiii
  • 0xfaner
  • 编程资料
  • 要做的事
© 2020 之伊丶
0%