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
in_prod.cpp
Upload User: dq031136
Upload Date: 2022-08-08
Package Size: 802k
Code Size: 1k
Category:
Visual C++ Books
Development Platform:
C++ Builder
- // If you use Visual C++, set the compile options to /GX
- #ifdef __BCPLUSPLUS__
- #include <iostream.h>
- #include <vector.h>
- #include <numeric.h>
- #include <iterator.h>
- #else
- #include <iostream>
- #include <vector>
- #include <numeric>
- #include <iterator>
- #endif
- using namespace std;
- typedef vector<float> FloatArray;
- typedef ostream_iterator<float, char, char_traits<char>>
- FloatOstreamIt;
- void main(void)
- {
- FloatOstreamIt itOstream(count, " ");
- //Initialize the arrays
- FloatArray rgF1, rgF2;
- for (int i=1; i<=5; i++)
- {
- rgF1.push_back(i);
- rgF2.push_back(i*i);
- };
- //print the arrays
- cout << "Array 1: ";
- copy(rgF1.begin(), rgF1.end(), itOstream);
- cout << endl;
- cout << "Array 2: ";
- copy(rgF2.begin(), rgF2.end(), itOstream);
- cout << endl;
- //This is the sum of the products (S.O.P) of the corresponding elements
- float ip1 = inner_product(rgF1.begin(), rgF1.end(), rgF2.begin(), 0);
- cout << "The inner product (S.O.P.) of Array and Array2 is " << ip1 << endl;
- //This is the product of the sums (P.O.S.) of the corresponding elements
- float ip2 = inner_product(rgF1.begin(), rgF1.end(), rgF2.begin(), 1,
- multiplies<float>(), plus<float>());
- cout << "The inner product (P.O.S.) of Array2 is " << ip2 << endl;
- }