struct Student {
int id;
char name[20];
float score;
struct Student *next;
};
struct Node {
int data;
struct Node *next;
};

struct TreeNode {
int data;
struct TreeNode *left;
struct TreeNode *right;
};
void insertionSort(int arr[], int n) {

for (int i = 1; i < n; i++) {
int key = arr[i];
int j = i - 1;
while (j >= 0 && arr[j] > key) {
arr[j + 1] = arr[j];
j--;
}
arr[j + 1] = key;
}
}
// 不佳的内存布局 struct BadLayout {
char a; // 1字节
int b; // 4字节 - 需要3字节填充
char c; // 1字节
}; // 总共12字节

// 优化的内存布局
struct GoodLayout {
int b; // 4字节
char a; // 1字节
char c; // 1字节
}; // 总共8字节(假设4字节对齐)
免责声明:本网站部分内容由用户自行上传,若侵犯了您的权益,请联系我们处理,谢谢!联系QQ:2760375052








