My coding way (1)
2015-10-21 23:41
169 查看
问题 A: 【C语言训练】计算t=1+1/2+1/3+...+1/n
时间限制: 1 Sec 内存限制: 128 MB题目描述
计算t=1+1/2+1/3+...+1/n输入
整型变量n输出
t(保留六位小数)样例输入
10样例输出
2.928968This is my first time using CSDN blog system. If anthing is wrong, please contact me as soon as possible ~
#include <stdio.h> int main() { int n; double ans=0; scanf("%d",&n); for(;n>0;n--) { ans+=1.0/n; } printf("%.6lf \n",ans); return 0; }
相关文章推荐
- PHP学习攻略 教你高效快速成为技术高手
- 作业
- Nginx 1.5.2 + PHP 5.5.1 + MySQL 5.6.10 在 CentOS 下的编译安装
- centos 7 min 编译安装php5.6+nginx1.7.5 笔记
- UVA_1605: Building for UN
- 从源码角度深入理解LayoutInflater
- CodeForces - 369E Valera and Queries(树状数组)
- 从源码角度深入理解LayoutInflater
- 从源码角度深入理解LayoutInflater
- Swift初体验之重写应用程序启动
- php学习进阶攻略
- spring 核心技术
- 从源码角度深入理解LayoutInflater
- Android中保存数据的四种方法
- Dexposed热更新-偷偷改掉你的bug
- 把问题倒过来
- log4j配置
- Android_08_创建,启动和关闭远程服务
- torch学习(三) training
- Spring的特点