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

//1:3:5:7:8:20:28:40
//80080800D5
//213,0,8,8,128,0,0,0

//#define ZXIC

#ifdef ZXIC
#define BAND_WIDTH 8
#else
#define BAND_WIDTH 4
#endif

int str_reverse(char *str)
{   
    int i, j;
    char c;
    
    if (NULL == str || (j = strlen(str)) == 0)
        return -1;
    
    for (i = 0, j--; i < j; i++, j--) {
        c = str[i];
        str[i] = str[j];
        str[j] = c;
    }
    
    return 0;
}

void get_band_value(int band, int *offset, int *value)
{
    int temp;

    *offset = band / BAND_WIDTH;
    temp = band % BAND_WIDTH;
    if (temp == 0) {
        (*offset)--;
#ifdef ZXIC
        temp = BAND_WIDTH;
#else
        temp = 2 * BAND_WIDTH;
#endif
    }
#ifdef ZXIC
    *value = pow(2, temp - 1);
#else
    if (temp == BAND_WIDTH - 1) {
        temp = BAND_WIDTH;
    }
    *value = temp;
#endif
}

int get_frequency_bands(char *band, char *bandBuf)
{
    int bandValue, offset, value;
    char *ptr = NULL, temp[64] = {0};
#ifdef ZXIC
    int i, tempBuf[9] = {0};
#endif

    if (NULL == band || NULL == bandBuf || strlen(band) == 0)
        return -1;

    memcpy(temp, band, strlen(band));
    if ((ptr = strtok(temp, ":")) == NULL) {
        ptr = temp;
    }
    do {
        if ((bandValue = atoi(ptr)) <= 0)
            return -1;
        get_band_value(bandValue, &offset, &value);
#ifdef ZXIC
        tempBuf[offset] += value;
#else
        bandBuf[offset] += value;
        if (bandBuf[offset] > '9') {
            bandBuf[offset] += ('A' - '9' - 1);
        }
#endif
        ptr = strtok(NULL, ":");
    } while (ptr);
#ifdef ZXIC
    offset = 0;
    for (i = 0; i < BAND_WIDTH; i++) {
        offset += sprintf(&bandBuf[offset], "%d,", tempBuf[i]);
    }
    bandBuf[--offset] = '\0';
#else
    bandBuf[++offset] = '\0';
#endif

#ifdef ZXIC
    return 0;
#else
    return str_reverse(bandBuf);
#endif
}

int main(int argc, char *argv[])
{
    char band[32] = "00000000000000000000";

    get_frequency_bands("1:3:5:7:8:20:28:40", band);
    printf("band:%s\n", band);

    return 0;
}

#include <stdio.h>

void print_diamond(int n)
{
    int i, j, k;

    k = 2 * n - 1;
    for (i = 0; i < n; i++) {
        for (j = 1; j <= k; j++) {
            if (j >= n - i && j <= n + i) {
                printf("*");
            } else {
                printf(" ");
            }
        }
        printf("\n");
    }
    for (i = 1; i < n; i++) {
        for (j = 1; j <= k; j++) {
            if (j > i && j <= k - i) {
                printf("*");
            } else {
                printf(" ");
            }
        }
        printf("\n");
    }
}

int main(int argc, char *argv[])
{
    print_diamond(7);

    return 0;
}

导出:

mysqldump -u UserName -p DatabaseName > DatabaseName.sql

导入:

mysql -u UserName -p DatabaseName < DatabaseName.sql

连接:mysql -u UserName -p
创建数据库:create database DatabaseName;
删除数据库:drop database DatabaseName;
查看数据库列表:show databases;
选择数据库:use DatabaseName;
显示表:show tables;
表结构:describe TabelName;
表数目:select count(*) from information_schema.tables where table_schema='DatabaseName';
查看权限:select * from mysql.user where user='UserName'\G
查看权限:show grants for UserName@host;
查询用户:select user,host from mysql.user;
授权所有权限:grant all privileges on DatabaseName.* to UserName@host identified by 'password';

https://prismjs.com/
进入下载页 选择 Languages Themes
下载 JS CSS
将 prism.js prism.css 上传至 /usr/themes/default
在 header.php </head>前插入

<link rel="stylesheet" href="<?php $this->options->themeUrl('prism.css'); ?>">
<script src="<?php $this->options->themeUrl('prism.js'); ?>"></script>

在代码块标记 ``` 后添加语言名

wget https://github.com/typecho/typecho/releases/latest/download/typecho.zip
unzip typecho.zip
安装时上传目录无法写入:chmod o+w uploads

/usr/local/nginx/conf/vhost/host.conf
后台404:将 enable-php.conf 改为 enable-php-pathinfo.conf
IP地址访问网站:server_name 添加IP地址
重启nginx:/usr/local/nginx/sbin/nginx -s reload

侧边栏不显示最近回复与其他:
/themes/default/sidebar.php 注释 ShowRecentComments ShowOther
或者在 控制台 设置外观 去勾选 显示最近回复 显示其他杂项

禁用评论:控制台 个人设置 撰写设置 默认允许 去勾选 可以被评论

不显示"评论":/themes/default/index.php 注释 interactionCount
不显示点击作者后的"评论":/themes/default/archive.php 注释 interactionCount

自定义后台路径:config.inc.php define('__TYPECHO_ADMIN_DIR__', '/admin/');

后台不显示"最近得到的回复":index.php 注释 '最近得到的回复'对应的div

首页不显示"关于":/themes/default/header.php 注释 \Widget\Contents\Page 至 endwhile