按下面的公式求sum的值 程序编程题 sum=m-(m+1)+(m+2)-(m+3)+.按下面的公式求sum的值程序编程题sum=m-(m+1)+(m+2)-(m+3)+.+(n-1)-n例如,如果m和n的值分别为1和100,只计算结果为-50.#include "stdio.h"#include "math.h"#include "conio.h"#include "stdlib.h"fun( int m,int n){ //}main(){ int m,n,t;scanf("%d,%d",&m,&n);if(m>n){ t=m; m=n; n=t; }printf("sum=%d\n",fun(m,n));NONO( );}NONO( ){ FILE *fr,*fw;int i,m,n;fr = fopen("C:\\homework\\10010131\\PROGIN.DAT","r");fw = fopen("C:\\homework\\10010131\\PROGOUT.DAT","w"
按下面的公式求sum的值 程序编程题 sum=m-(m+1)+(m+2)-(m+3)+.
按下面的公式求sum的值
程序编程题
sum=m-(m+1)+(m+2)-(m+3)+.+(n-1)-n
例如,如果m和n的值分别为1和100,只计算结果为-50.
#include "stdio.h"
#include "math.h"
#include "conio.h"
#include "stdlib.h"
fun( int m,int n)
{
//
}
main()
{ int m,n,t;
scanf("%d,%d",&m,&n);
if(m>n)
{ t=m; m=n; n=t; }
printf("sum=%d\n",fun(m,n));
NONO( );
}
NONO( )
{ FILE *fr,*fw;
int i,m,n;
fr = fopen("C:\\homework\\10010131\\PROGIN.DAT","r");
fw = fopen("C:\\homework\\10010131\\PROGOUT.DAT","w") ;
for(i=1; i
hvm
应该是
//