自动化1122徐达武第四周剩下的作业
来源:互联网 发布:sigma.js 示例 编辑:程序博客网 时间:2024/04/28 11:23
1.1
#include<iostream.h>
#include<iomanip.h>
int main()
{
int i,j;
double e=1,s=1;
for(i=1;i<=10;i++)
{
for(j=1;j<=i;j++)
{
s*=j;
}
e+=1/s;
s=1;
}
cout<<"e="<<setprecision(8)<<e<<endl;
return 0;
}
setprecision()函数是用来控制输出流显示浮点数的数字个数,使用头文件#include<iomanip.h>
1.2
#include <iostream.h> #include <cmath.h> int main() { int i; double pai=0,fac=1; for(i=1;i<10e6;i+=2) { pai+=4*(double)1/i*fac; fac*=-1; } cout << "pai约等于:"<<pai<<endl; return 0; }
1.3
#include<iostream> #include<iomanip> using namespace std; int main() { int j,i; for(i=1; i<=4; i++) { for(j=1; j<=5-i; j++) cout<<setw(2)<<" "; for(j=1;j<=2*i-1;j++) cout<<setw(2)<<'*'; cout<<endl; } for(i=1;i<=3;i++) { for(j=4;j>=4-i;j--) cout<<setw(2)<<" "; for(j=4;j>=2*i-2;j--) cout<<setw(2)<<'*'; cout<<endl; } return 0; }
setw()作用是设置显示的宽度
#include<iostream>using namespace std;void main(){double i=0,j=0.1;for(int day=0;day<30;day++){i+=100000;j=j*2;}cout<<"陌生人给了富翁:"<<i<<"元"<<endl;cout<<"富翁给了陌生人:"<<j<<"元"<<endl;}
0 0
- 自动化1122徐达武第四周剩下的作业
- 第四周的作业
- 自动1122徐达武第六章剩下作业
- 第四周作业的抄写部分
- 第四周作业 -- 图的表示
- 第四周作业--图的表示
- 第四周作业—图的表示
- 第四周作业---图的表示
- 第四周作业-图的表示
- 第四周作业-图的表示
- 第四周作业---图的表示
- 第四周作业—图的表示
- 第四周作业--图的表示
- 第四周作业—图的表示
- 第四周java作业,图的表示
- 第四周作业—图的表示
- 第四周作业,图的表示
- 第四周作业:图的表示
- 第5周作业-字体设置
- 一步步学习 Spring Data 系列之JPA(一)
- Firmware 加载原理分析
- gossip_0304
- java 泛型笔记
- 自动化1122徐达武第四周剩下的作业
- 学习<opencv> CascadeClassifier::detectMultiScale 各个参数作用
- javascript替换所有反斜杠”\“的写法
- HTTP 协议实例
- 前端笔试题阿里篇 之一-- css,js打造rating打分效果
- 软考笔记(一)
- 解决Matlab中load一个mat文件时出现The element type "name" must be terminated by the matching end-tag "</name>"的
- HDU 4442 Physical Examination
- mysql 数据库 错误 Data truncation: Data too long for column 'name' at row 1