重构:规范代码格式,拆分 add() 声明与实现

This commit is contained in:
2026-11-16 15:19:41 +08:00
parent 872598f1b1
commit 200e43c18f
5 changed files with 43 additions and 13 deletions
+1
View File
@@ -0,0 +1 @@
/test-project
+22
View File
@@ -0,0 +1,22 @@
# Test-Project
用于测试 Muse-AI 与 Gitea 的协作。
## 结构
- `main.c`:程序入口,打印问候语和加法结果。
- `add.h` / `add.c`:`add()` 函数的声明与实现。
## 构建与运行
```sh
gcc -Wall -Wextra -std=c11 main.c add.c -o test-project
./test-project
```
输出:
```text
Hello World!
10 + 20 = 30
```
+4 -9
View File
@@ -1,11 +1,6 @@
#include <stdio.h>
#include "add.h"
int add(int a, int B) { return a+ B;}
int main() {
int a, b, c;
a = 10;b=20;
c= add (a ,b);
printf("%d", c);
return 0;
int add(int a, int b)
{
return a + b;
}
+6
View File
@@ -0,0 +1,6 @@
#ifndef TEST_PROJECT_ADD_H
#define TEST_PROJECT_ADD_H
int add(int a, int b);
#endif /* TEST_PROJECT_ADD_H */
+10 -4
View File
@@ -1,9 +1,15 @@
#include <stdio.h>
int main() {
printf("Hell0 World!");
return 0 ;
#include "add.h"
int main(void)
{
int a = 10;
int b = 20;
int sum = add(a, b);
printf("Hello World!\n");
printf("%d + %d = %d\n", a, b, sum);
}
return 0;
}