Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
f0610.cpp
Package: c.rar [view]
Upload User: puke2000
Upload Date: 2022-07-25
Package Size: 912k
Code Size: 1k
Category:
CSharp
Development Platform:
Visual C++
- //==================================
- // f0610.cpp
- // 矩形积分
- //==================================
- #include<iostream>
- #include<fstream>
- #include<cmath>
- using namespace std;
- //----------------------------------
- double g(double x){
- return 1/x;
- }//---------------------------------
- double rectangle(double a, double b, double(*f)(double)){
- double w=b-a, sumNew=w*(f(a)+f(b))/2, sumOld=0;
- for(int n=1; abs(sumNew-sumOld)>=1e-4; n*=2){
- sumOld=sumNew;
- sumNew=0;
- for(int i=0; i<n; ++i)
- sumNew += f(a + w*(i+0.5)/n);
- sumNew *= w/n;
- }
- return sumNew;
- }//---------------------------------
- int main(){
- ifstream in("integral.txt");
- cout<<fixed; cout.precision(3);
- for(double b; in>>b; )
- cout<<rectangle(1,b,g)<<"n";
- }//=================================