#include<stdio.h>
//计算1~N之间所有奇数之和 这个怎么编写
//第一个求出奇数:if(n % 2 == 1)
//第二步求和
sum += n;
int judgeOrder(int x);
int sum(int i,int n);
main()
{
int i;
int n;
printf("请输入你要求的从i ~ N之间的奇数和:\n");
scanf("%d%d",&i,&n);
//输chu
printf("%d",sum(i,n));
}
int judgeOrder(int x)
{
int n = x;
if(n % 2 == 1)
return 1;
else
return 0;
}
int sum(int i,int n)
{
int sum = 0;
for(i; i <= n; i++)
{
if(judgeOrder(i))
{
//printf("%d ",i);
sum += i;
}
}
return sum;
}