功能:求x到y之间的奇数和(包括x和y)。#inclu

功能:求x到y之间的奇数和(包括x和y)。

#include<stdio.h> 
int fun(int x,int y)
{
    int i,s=0;
    for(_____1_____)
        if(_____2_____)
            _____3_____
    _____4_____
}
void TestFunc()
{
    FILE *IN,*OUT;
    int n;
    int i[2];
    int o;
    IN=fopen("in.dat","r");
    if(IN==NULL)
    {
        printf("Read File Error");
    }
    OUT=fopen("out.dat","w");
    if(OUT==NULL)
    {
        printf("Write File Error");
    }
    for(n=0;n<2;n++)
    {   
        fscanf(IN,"%d",&i[n]);
    }
    o = fun(i[0],i[1]);
    fprintf(OUT,"%d\n",o);
    fclose(IN);
    fclose(OUT);
}
void main()
{
    int s;
    s=fun(1,1999);
    printf("s=%d\n",s);
    TestFunc();
}


答案
第1空:i=x;i<=y;i++
第2空:i%2!=0
第3空:s=s+i;
第4空:return s;

题目信息

题号:6757
题型:填空题
难度:普通