day8 homework: 静态的生成和使用题目练习
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
#include "a.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int factorial(int n)
|
||||
{
|
||||
if (n == 0)
|
||||
return 1;
|
||||
else
|
||||
return n * factorial(n - 1);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef __A_H__
|
||||
#define __A_H__
|
||||
|
||||
int factorial(int); // 声明阶乘函数
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "b.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int *arrSort(int arrInput[], int arrlen)
|
||||
{
|
||||
int i, j, temp;
|
||||
for (i = 0; i < arrlen - 1; i++)
|
||||
{
|
||||
for (j = 0; j < arrlen - 1 - i; j++)
|
||||
{
|
||||
if (arrInput[j] > arrInput[j + 1])
|
||||
{
|
||||
temp = arrInput[j];
|
||||
arrInput[j] = arrInput[j + 1];
|
||||
arrInput[j + 1] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
return arrInput;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef __B_H__
|
||||
#define __B_H__
|
||||
|
||||
int *arrSort(int arrInput[], int arrlen); // 声明数组排序函数
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user