Initial commit: C language learning code
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
int num_sum(int a, int b) // 函数定义
|
||||
{
|
||||
int sum = 0;
|
||||
for (int i = a; i <= b;i++)
|
||||
{
|
||||
sum += i;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int a, b;
|
||||
printf("请输入两个整数:");
|
||||
scanf("%d %d", &a, &b);
|
||||
printf("%d和%d之间的所有数的和:sum = %d\n", a, b, num_sum(a, b));
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user