下面展示一些 内联代码片
。
// A code block
var foo = 'bar';
// An highlighted block
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// 商品结构体
typedef struct {
int id; // 商品编号
char name[20]; // 商品名称
float price; // 商品价格
int stock; // 商品库存量
} Commodity;
Commodity commoditys[100];
typedef struct BSTNode {
Commodity commodity; // 商品信息
Commodity data;
struct BSTNode *next;
struct BSTNode* left;
struct BSTNode* right;
} BSTNode;
// 二叉排序树节点
#define MAX_SIZE 1000
Commodity data[MAX_SIZE]; // 全局数组,用于存储商品信息
int size = 0; // 当前存储的商品数量
// 增加商品
void addCommodity() {
if (size >= MAX_SIZE) {
printf("仓库已满。\n");
return;
}
Commodity commodity;
// 输入商品信息
printf("请输入商品信息:\n");
printf("编号:");
scanf("%d", &commodity.id);
printf("名称:");
scanf("%s", commodity.name);
printf("价格:");
scanf("%f", &commodity.price);
printf("库存量:");
scanf("%d", &commodity.stock);
// 将商品信息添加到数组中
data[size++] = commodity;
printf("添加商品成功。\n");
}