用VC++编写程序。求1+1/2+1/3+……..+1/20.

如题所述

double sum = 0.0;
for(double i = 1.0; i < 21.0; i++){
sum += 1.0 / i;
}
温馨提示:答案为网友推荐,仅供参考