examples.c
来自「深入理解计算机系统 的lab」· C语言 代码 · 共 51 行
C
51 行
/* * Architecture Lab: Part A * * High level specs for the functions that the students will rewrite * in Y86 assembly language *//* $begin examples *//* linked list element */typedef struct ELE { int val; struct ELE *next;} *list_ptr;/* sum_list - Sum the elements of a linked list */int sum_list(list_ptr ls){ int val = 0; while (ls) { val += ls->val; ls = ls->next; } return val;}/* rsum_list - Recursive version of sum_list */int rsum_list(list_ptr ls){ if (!ls) return 0; else { int val = ls->val; int rest = rsum_list(ls->next); return val + rest; }}/* copy_block - Copy src to dest and return xor checksum of src */int copy_block(int *src, int *dest, int len){ int result = 0; while (len > 0) { int val = *src++; *dest++ = val; result ^= val; len--; } return result;}/* $end examples */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?