c - 如何在 C 语言中使用#define 定义静态矩阵?

标签 c matrix static static-libraries c-preprocessor

#define指令中你可以定义一个静态数组,但我不明白你如何定义一个静态矩阵?。我想创建一个静态矩阵库。

谁能帮帮我?

最佳答案

我猜你想像下面这样使用它:

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

const int matrix[3][4]=
{
    {1, 5, 6, 7},
    {4, 4, 8, 0},
    {2, 3, 4, 5}
};

int main()
{
    int i, j;
    for(i = 0; i< 3; i++)
    {
        for(j = 0; j<4; j++)
        {
            printf("%d ", matrix[i][j]);
        }
        printf("\n");
    }
}

关于c - 如何在 C 语言中使用#define 定义静态矩阵?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24927110/

相关文章:

php - 如何在静态方法中使用 'this' - PHP PDO

java - @PostConstruct执行中@Value静态注解为null

c - 使用Core Audio实时生成正弦音

c - K&R C书中的atoi函数

java - 使用矩阵和重复平方计算斐波那契数

c++ - C++ 中的二维数组

java - Drools 引用静态场

使用 C 创建一个 tar.gz 文件

c - 带有 2 个 UDP 客户端的 UDP 服务器

iphone - 使用 Accelerate (CLAPACK) 求解压缩列存储矩阵(在 xcode 中)?