#include
void main()
{
int m = 0, i, j = 0;
while((m % 2) == 0)
{
printf("Please input a odd number: ");
scanf("%d", &m);
for(i = 1; i <= m; i += 2)
j += i;
while(getchar() != '\n')
;
}
printf("%d\n", j);
}
#include
main()
{
int n,sum=0,i;
printf("请输入n:");
scanf("%d",&n);
if(n%2==0)
printf("输入错误");
else if(n%2!=0)
{
for(i=1;i<=n;i+=2)
{
sum=sum+i;
}
printf("sum=%d",sum);
}
}
#include
int main(void)
{
int a, b = 0, i;
printf("\n输入一个奇数:");
scanf("%d",&a);
if(a % 2 == 0 || a < 0)
printf("输入错误!\n");
else
{
for(i = 1;i <= a; i += 2)
b += i;
printf("%d\n",b);
}
return 0;
}