重构:规范代码格式,拆分 add() 声明与实现
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
/test-project
|
||||||
@@ -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
|
||||||
|
```
|
||||||
@@ -1,11 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include "add.h"
|
||||||
|
|
||||||
int add(int a, int B) { return a+ B;}
|
int add(int a, int b)
|
||||||
|
{
|
||||||
int main() {
|
return a + b;
|
||||||
int a, b, c;
|
|
||||||
a = 10;b=20;
|
|
||||||
c= add (a ,b);
|
|
||||||
printf("%d", c);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 */
|
||||||
Reference in New Issue
Block a user