Diablo背包功能C++实现

Diablo – 暗黑破坏神暴雪娱乐(Blizzard Entertainment)旗下系列品牌。

一些题外话

1998年,笔者接触到了Diablo 1,被其游戏性折服;2002年暑假,与小伙伴联机Diablo 2为了一件装备的归属吵来吵去;2012年,没有第一时间买到Diablo 3亚洲服务器的激活码,最后只能在奸商的抬价中以近1.5倍的原价入手。

经历了Diablo 1~3,可以很明显感觉到游戏系统的丰富、游戏画质的提升、游戏历史的延展,但是如果有人问我:提起Diablo你首先联想到的会是什么?我会回答:背包与装备系统。

Read More →

二级指针的作用分析

二级指针 – pointer to pointer

简单举例说明下这是一个什么神奇的东西,首先定义

const char *c = "hello";

我们虚拟展示一块内存(地址值与地址分配,包括机器位数都是人为虚拟设置的)

1

Read More →

深入理解C/C++形参、传指针、传引用

一则经典的问题:

//为了突出程序主要目的,忽略了malloc()分配是否成功检查与free()相关逻辑
//这是第一段代码
struct test {
    int num;
};

void change_value(struct test *out)
{
    struct test *in = (struct test *)malloc(sizeof(struct test));
    in->num = 100;
    out = in;
    printf("in num:%d\n",out->num);
}

int main()
{
    struct test *out = (struct test *)malloc(sizeof(struct test));
    out->num = 0;

    change_value(out);

    printf("out num:%d\n",out->num);
    return 0;
}

Read More →

Empire Problem

上周以前大学同学分享探讨了一个编程问题,觉得还是挺有典型意义的(解法与题意理解上)。故在此记录下。

Problem
The empire has a capitol and a number of cities. Some cities are connected to other cities. A route connecting two cities can transport a message in both directions. All cities are reachable using some path from the capitol city. The connections among all cities are described in an adjacency matrix with the format shown below. At the start, a message is sent from the capitol city to all other cities, and we want to know what’s the minimal time for a message to spread out from the capitol to the whole empire.
Read More →