设m,n为正整数,m<n,求m到n的自然数倒数之和,c语言求不用return,c语言初学者, 5
展开全部
//#include "stdafx.h"//If the vc++6.0, with this line.
#include "stdio.h"
int main(void){
int m,n;
double sum;
while(1){
printf("Input m & n(int m<n)...\n");
scanf("%d%d",&m,&n);
if(m<n) break;
printf("Error, redo: ");
}
for(sum=0;m<=n;m++)
sum+=1.0/m;
printf("The result is %g\n",sum);
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询