注册 登录
编程论坛 闲聊灌水

我要把我之前的帖子都删掉,然后以一个神的形象出现在bccn

BlueGuy 发布于 2015-06-03 23:01, 987 次点击
其实,11 年的时候,我感觉的我技术就已经相当厉害了,只是那个时候经验少,发了很多幼稚的帖子
然后,我又做了4年的网络游戏。

还有,我是 C 语言论坛2010度历届版主哦~
我能够被称为高手么?

[ 本帖最后由 BlueGuy 于 2015-6-3 23:33 编辑 ]
22 回复
#2
zklhp2015-06-04 01:32
高手您好
#3
wmf20142015-06-04 05:09
高手就是高手,不是版主也能删
#4
tlliqi2015-06-04 05:59
手8低
#5
hu9jj2015-06-04 07:03
以下是引用wmf2014在2015-6-4 05:09:11的发言:

高手就是高手,不是版主也能删

既然是高手,就没有办不成的事情。
#6
wangnannan2015-06-04 08:34
楼主应该把这个帖子发到C板块 让大家叫你神

[ 本帖最后由 wangnannan 于 2015-6-4 08:38 编辑 ]
#7
DragonWarrior2015-06-04 09:03
楼主是神 鉴定完毕
#8
冰镇柠檬汁儿2015-06-04 09:29
你的帖子现在一样很幼稚
#9
诸葛欧阳2015-06-04 09:29
膜拜一下
#10
BlueGuy2015-06-04 10:36
回复 8楼 冰镇柠檬汁儿
比你的帖子成熟很多了
#11
wangnannan2015-06-04 10:56
目测 看了下楼主的陈年老贴 https://bbs.bccn.net/thread-350824-4-1.html
楼主能够说自己以前的帖子幼稚 恭喜楼主长大了

[ 本帖最后由 wangnannan 于 2015-6-4 11:58 编辑 ]
#12
zklhp2015-06-04 11:53
以下是引用wangnannan在2015-6-4 10:56:47的发言:

目测 看了下楼主的陈年老贴 https://bbs.bccn.net/thread-350824-4-1.html

#13
纳兰伽香2015-06-04 15:05
以下是引用wangnannan在2015-6-4 10:56:47的发言:

目测 看了下楼主的陈年老贴 https://bbs.bccn.net/thread-350824-4-1.html
楼主能够说自己以前的帖子幼稚 恭喜楼主长大了

楼主当年 太霸气
#14
冰镇柠檬汁儿2015-06-04 16:58
以下是引用BlueGuy在2015-6-4 10:36:31的发言:

比你的帖子成熟很多了

https://bbs.bccn.net/thread-361127-1-1.html
好吧,你赢了
#15
BlueGuy2015-06-04 17:30
回复 14楼 冰镇柠檬汁儿
你应该看看我 2011年1月 写的广度优先搜索
https://bbs.bccn.net/thread-331463-1-1.html

程序代码:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define NUM 5

typedef struct bgMatrix
{
    int v, w;
    char matrix[NUM][NUM];
    int pre;
}Matrix;

typedef struct bgQueue
{
    Matrix* data;
    int maxLength;
    int head;
    int tail;
}BGQueue;
typedef BGQueue* Queue;

typedef struct bgStack
{
    Matrix* data;
    int top;
}BGStack;
typedef BGStack* Stack;

char srcMatrix[NUM][NUM] =
{
    {'*', '*', '*', '*', '*'},
    {'*', '2', '8', '3', '*'},
    {'*', '1', '0', '4', '*'},
    {'*', '7', '6', '5', '*'},
    {'*', '*', '*', '*', '*'}
};

char dstMatrix[NUM][NUM] =
{
    {'*', '*', '*', '*', '*'},
    {'*', '1', '2', '3', '*'},
    {'*', '8', '0', '4', '*'},
    {'*', '7', '6', '5', '*'},
    {'*', '*', '*', '*', '*'}
};

int dx[4] = {0, -1, 0, 1};

int dy[4] = {-1, 0, 1, 0};

int cnt = -1;

Queue queue;

Stack stack;

FILE* log;

void bfs(Matrix matrix);

void initQueue(int length);

void putQueue(Matrix matrix);

Matrix getQueue(void);

int isQueueEmpty(void);

int isQueueFull(void);

void initStack(int length);

void pushStack(Matrix matrix);

Matrix popStack(void);

int isStackEmpty(void);

int matrixCmp(char src[][NUM], char dst[][NUM]);

void matrixCpy(char dst[][NUM], char src[][NUM]);

void matrixPrint(char matrix[][NUM]);

void bgOpenLog(void);

void bgWriteLog(const char* s);

void bgCloseLog(void);

int main(void)
{
    Matrix src;
   
    bgOpenLog();
   
    initQueue(3628800);
    initStack(1000);

    src.v = 2;
    src.w = 2;
    matrixCpy(src.matrix, srcMatrix);
    src.pre = cnt;
   
    bfs(src);
   
    bgCloseLog();
   
    getchar();
   
    return 0;
}

void bfs(Matrix matrix)
{
    Matrix s, t;
   
    int v, w;
   
    int direction, tmp;
   
    putQueue(matrix);
   
    while (!isQueueEmpty())
    {
        t = getQueue();
        
        if (!matrixCmp(t.matrix, dstMatrix))
        {
            cnt++;
            
            for (direction = 0; direction < 4; direction++)
            {
                s = t;
                v = s.v + dx[direction]; w = s.w + dy[direction];
               
                if (srcMatrix[v][w] != '*')
                {
                    tmp = s.matrix[s.v][s.w];
                    s.matrix[s.v][s.w] = s.matrix[v][w];
                    s.matrix[v][w] = tmp;
                    
                    s.v = v;
                    s.w = w;
                    s.pre = cnt;
                    
                    for (tmp = 0; tmp < queue->tail; tmp++)
                    {
                        if (matrixCmp(queue->data[tmp].matrix, s.matrix))
                        {
                            break;
                        }
                    }
                    if (tmp == queue->tail)
                    {
                        putQueue(s);
                    }
                }
            }
        }
        else
        {
            pushStack(t);
            
            for (tmp = t.pre; !matrixCmp(queue->data[tmp].matrix, srcMatrix); tmp = queue->data[tmp].pre)
            {
                pushStack(queue->data[tmp]);
            }

            matrixCpy(t.matrix, srcMatrix);
            pushStack(t);

            while (!isStackEmpty())
            {
                t = popStack();
                matrixPrint(t.matrix);
            }

            printf("Hi, BlueGuy");

            return;
        }
    }
}

void initQueue(int length)
{
    queue = malloc(sizeof(BGQueue));
   
    queue->data = malloc(sizeof(Matrix) * length);
    queue->maxLength = length;
    queue->head = 0;
    queue->tail = 0;
}

void putQueue(Matrix matrix)
{
    queue->data[queue->tail++] = matrix;
    queue->tail = queue->tail % queue->maxLength;
}

Matrix getQueue(void)
{
    Matrix ret;
   
    ret = queue->data[queue->head++];
    queue->head = queue->head % queue->maxLength;
   
    return ret;
}

int isQueueEmpty(void)
{
    return queue->head == queue->tail;
}

int isQueueFull(void)
{
    return ((queue->tail+1) % queue->maxLength) == queue->head;
}

void initStack(int length)
{
    stack = malloc(sizeof(BGStack));
   
    stack->data = malloc(sizeof(Matrix) * length);
    stack->top = 0;

}

void pushStack(Matrix matrix)
{

    stack->data[stack->top++] = matrix;
}

Matrix popStack(void)
{
    Matrix ret;
    ret = stack->data[--stack->top];
   
    return ret;
}

int isStackEmpty(void)
{
    return (stack->top == 0);
}



int matrixCmp(char src[][NUM], char dst[][NUM])
{
    int i, j, s, t, ret;
   
    char srcString[30] = {0};
    char dstString[30] = {0};
   
    s = 0;
    t = 0;
   
    for (i = 0; i < NUM; i++)
    {
        for (j = 0; j < NUM; j++)
        {
            srcString[s++] = src[i][j];
            dstString[t++] = dst[i][j];
        }
    }
   
    ret = !strcmp(srcString, dstString);
   
    return ret;
}


void matrixCpy(char dst[][NUM], char src[][NUM])
{
    int i, j;
   
    for (i = 0; i < NUM; i++)
    {
        for (j = 0; j < NUM; j++)
        {
            dst[i][j] = src[i][j];
        }
    }
}

void matrixPrint(char matrix[][NUM])
{
    char logTxt[60] = {0};
   
    int i, j, k;
   
    k = 0;
   
    for (i = 0; i < NUM; i++)
    {
        for (j = 0; j < NUM; j++)
        {
            logTxt[k++] = matrix[i][j];
        }
        
        logTxt[k++] = '\r';
        logTxt[k++] = '\n';
    }
   
    logTxt[k++] = '\r';
    logTxt[k++] = '\n';
   
    bgWriteLog(logTxt);
   
}

void bgOpenLog(void)
{
    if(log == NULL)
    {
        log = fopen("log.txt", "wb");
    }
}

void bgWriteLog(const char* s)
{
    fwrite(s, sizeof(char), strlen(s), log);
}

void bgCloseLog(void)
{
    fclose(log);
    log = NULL;
}


[ 本帖最后由 BlueGuy 于 2015-6-4 17:57 编辑 ]
#16
BlueGuy2015-06-04 17:57
我觉得我写代码你看不懂
#17
纳兰伽香2015-06-04 17:59
以下是引用BlueGuy在2015-6-4 17:57:26的发言:

我觉得我写代码你看不懂

感觉你  满腔愤恨   说话可以换很多种方式的
#18
冰镇柠檬汁儿2015-06-04 18:02
光辉岁月啊

看你以前的帖子一样是喜欢说别人的不是,就只有你厉害呗,你赢了,我认输了,行了吧,我实在是不会贬低别人
#19
冰镇柠檬汁儿2015-06-04 18:03
以下是引用纳兰伽香在2015-6-4 17:59:22的发言:


感觉你  满腔愤恨   说话可以换很多种方式的

能说出那种话,不就证明他的幼稚吗
#20
BlueGuy2015-06-04 18:31
回复 17楼 纳兰伽香
https://bbs.bccn.net/thread-443607-2-1.html
上次给你写的组合代码,你现在看懂了么?我怀疑你还是看不懂
#21
BlueGuy2015-06-04 20:02
回复 18楼 冰镇柠檬汁儿
应该是比你厉害很多吧,调用 html 函数的几行代码也发来发去,感觉是第一天写代码一样
#22
BlueGuy2015-06-04 20:05
程序代码:

#include <stdio.h>
#include <string.h>

int a[] = {1, 2, 3, 4, 5};
void recursion(int* combination, int m, int n, int begin, int depth);

int main(void)
{
    int m = sizeof(a) / sizeof(a[0]);
    int n = 2;
   
    int* combination = (int*)malloc(sizeof(int) * m);
    recursion(combination, m, n, 1, 1);

    getchar();
    return 0;
}

void recursion(int* combination, int m, int n, int begin, int depth)
{
    int i, j;
   
    for (i = begin; i <= m; i++)
    {
        combination[depth] = i;
        
        if (depth == n)
        {
            for (j = 1; j <= n; j++)
            {
                printf("%d ", a[combination[j]-1]);
            }
            
            printf("\n");
        }
        else
        {
            recursion(combination, m, n, i+1, depth+1);
        }
    }
}
#23
林月儿2015-06-05 10:32
楼主的代码我这个菜鸟是看不懂了,希望楼主经常光顾C版带带我们这些新人。
1