在/***begin****/和/**end**/只见填空,计算出sum=1-1/3+1/5-1/7+…+(-1)^(n-1)(1/2n-1)保留4位小数。
#include"stdio.h"doublefun(intn){doublec;/***********begin***********//***********end...
#include "stdio.h"
double fun( int n )
{
double c;
/***********begin***********/
/***********end***********/
}
int main()
{
void NONO( );//函数声明
double sum;
int n;
printf("Enter n:\n");
scanf("%d",&n);
sum=fun(n);
printf("sum=%.4f\n",sum);
NONO( );
return 0;
}
void NONO( )
{ FILE *fr,*fw;
int i, x;
fr=fopen("E:\\homework\\10040220\\PROGIN.DAT","r");
fw=fopen("E:\\homework\\10040220\\PROGOUT.DAT","w");
for(i=1;i<=5;i++)
{ fscanf(fr,"%d",&x);
fprintf(fw,"s=%.4f\n",fun(x));}
fclose(fr);
fclose(fw);
} 展开
double fun( int n )
{
double c;
/***********begin***********/
/***********end***********/
}
int main()
{
void NONO( );//函数声明
double sum;
int n;
printf("Enter n:\n");
scanf("%d",&n);
sum=fun(n);
printf("sum=%.4f\n",sum);
NONO( );
return 0;
}
void NONO( )
{ FILE *fr,*fw;
int i, x;
fr=fopen("E:\\homework\\10040220\\PROGIN.DAT","r");
fw=fopen("E:\\homework\\10040220\\PROGOUT.DAT","w");
for(i=1;i<=5;i++)
{ fscanf(fr,"%d",&x);
fprintf(fw,"s=%.4f\n",fun(x));}
fclose(fr);
fclose(fw);
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询