轻松的编程学习
首页
题库
学习路径
在线商城
能力地图
下载应用
登录 / 注册
菜单
交付:五条验收条款一起过
👁️ 0 人浏览
💬 0 人评论
❤️ 添加收藏
(本条路线统一用
gcc -std=c11 -O0
编译)前两条已经写好了,把后三条补上。
提交你的答案
请登录后提交答案。
去登录
← 🔴 第四步:还干净,并且不留悬空的名字
Makefile 最主要替你省下的是什么 →
更多题目
改成"你好,有词"
输出"100 分"
把年龄改成 20
输出学习天数 30
修复:给文字加引号
修复:补上右括号
代码编辑器
语言:
python3
c11
cpp17
Ctrl
+
Enter
运行
👩🏫 AI
▶ 运行代码
重置代码
打印代码
#include <stdio.h> #include <stdlib.h> struct Node { int v; struct Node *next; }; static int got = 0, gave = 0; static struct Node *make(int v) { got++; struct Node *n = malloc(sizeof(struct Node)); if (n == NULL) return NULL; n->v = v; n->next = NULL; return n; } static struct Node *build(const int *a, int n) { struct Node *head = NULL, *tail = NULL; for (int i = 0; i < n; i++) { struct Node *x = make(a[i]); if (head == NULL) { head = tail = x; } else { tail->next = x; tail = x; } } return head; } static int total(const struct Node *h) { int s = 0; for (const struct Node *c = h; c != NULL; c = c->next) s += c->v; return s; } static void release(struct Node *h) { while (h != NULL) { struct Node *nx = h->next; gave++; free(h); h = nx; } } static int at(const int *a, int n, int i) { if (i < 0 || i >= n) return -1; return a[i]; } int main(void) { int a[4] = {10, 20, 30, 40}; int n = sizeof(a) / sizeof(a[0]); struct Node *head = build(a, n); int s = total(head); release(head); head = NULL; /* 五条验收条款,1 表示过 */ int c1 = (n == 4); /* 长度用比值算出来的 */ int c2 = (s == 100); /* 算得对 */ /* TODO: c3 —— 要的块数和还的块数相等(不漏) */ int c3 = 0; /* TODO: c4 —— 越界访问被拦下,交回的是 -1(不越界) */ int c4 = 0; /* TODO: c5 —— 还完之后 head 是 NULL(不留悬空的名字) */ int c5 = 0; printf("%d/%d/%d/%d/%d\n", c1, c2, c3, c4, c5); return 0; }
本次输入:
输出:
👩🏫
AI
请登录后使用 AI 老师
×
登录后可获得解题思路、提示与错误分析。
去登录
关闭
🎉
恭喜你,回答正确!
系统判定:正确
我知道了
💬 题目评论
提交
全部评论
全部评论