Click here to Skip to main content
15,914,795 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: vector of doubles (division) Pin
Stephen Hewitt27-May-10 21:40
Stephen Hewitt27-May-10 21:40 
GeneralRe: vector of doubles (division) Pin
Aescleal27-May-10 22:24
Aescleal27-May-10 22:24 
GeneralRe: vector of doubles (division) Pin
b-rad31128-May-10 5:24
b-rad31128-May-10 5:24 
GeneralRe: vector of doubles (division) Pin
Aescleal28-May-10 5:53
Aescleal28-May-10 5:53 
GeneralRe: vector of doubles (division) Pin
b-rad31128-May-10 6:05
b-rad31128-May-10 6:05 
GeneralRe: vector of doubles (division) Pin
Aescleal28-May-10 7:20
Aescleal28-May-10 7:20 
GeneralRe: vector of doubles (division) Pin
b-rad31128-May-10 7:28
b-rad31128-May-10 7:28 
AnswerRe: vector of doubles (division) Pin
Stephen Hewitt27-May-10 14:09
Stephen Hewitt27-May-10 14:09 
Here's one way:
// Console.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <functional>

int _tmain(int argc, _TCHAR* argv[])
{
	using namespace std;

	// Create and fill a vector.
	vector<double> nums;
	for (int i=1; i<=10; ++i)
		nums.push_back(i);

	// Print out the vector's contents.
	cout << "Before: ";
	copy(nums.begin(), nums.end(), ostream_iterator<double>(cout, " "));
	cout << endl << endl;

	// Divide all elements by two.
	transform(
		nums.begin(), nums.end(),
		nums.begin(),
		bind2nd(divides<double>(), 2.0)
		);

	// Print out the vector's contents.
	cout << "After: ";
	copy(nums.begin(), nums.end(), ostream_iterator<double>(cout, " "));
	cout << endl << endl;

	return 0;
}

Steve

GeneralRe: vector of doubles (division) Pin
b-rad31128-May-10 5:17
b-rad31128-May-10 5:17 
QuestionShow message the first time my app is started after windows has rebooted Pin
manchukuo27-May-10 6:48
manchukuo27-May-10 6:48 
AnswerRe: Show message the first time my app is started after windows has rebooted Pin
David Crow27-May-10 7:32
David Crow27-May-10 7:32 
GeneralRe: Show message the first time my app is started after windows has rebooted Pin
manchukuo27-May-10 7:45
manchukuo27-May-10 7:45 
GeneralRe: Show message the first time my app is started after windows has rebooted Pin
David Crow27-May-10 8:22
David Crow27-May-10 8:22 
GeneralRe: Show message the first time my app is started after windows has rebooted Pin
manchukuo27-May-10 9:11
manchukuo27-May-10 9:11 
GeneralRe: Show message the first time my app is started after windows has rebooted Pin
Iain Clarke, Warrior Programmer27-May-10 9:17
Iain Clarke, Warrior Programmer27-May-10 9:17 
GeneralRe: Show message the first time my app is started after windows has rebooted Pin
manchukuo27-May-10 9:20
manchukuo27-May-10 9:20 
AnswerRe: Show message the first time my app is started after windows has rebooted Pin
krmed27-May-10 8:59
krmed27-May-10 8:59 
AnswerRe: Show message the first time my app is started after windows has rebooted Pin
Bhaskar Sandbhor31-May-10 0:34
Bhaskar Sandbhor31-May-10 0:34 
QuestionHTTPS Pin
Fareed Rizkalla27-May-10 6:30
Fareed Rizkalla27-May-10 6:30 
AnswerRe: HTTPS PinPopular
Moak27-May-10 7:52
Moak27-May-10 7:52 
GeneralRe: HTTPS Pin
Stephen Hewitt27-May-10 19:42
Stephen Hewitt27-May-10 19:42 
QuestionProblem loading dll compiled in VS2005 on exe VS06 Pin
PrafullaShirke2727-May-10 6:01
professionalPrafullaShirke2727-May-10 6:01 
AnswerRe: Problem loading dll compiled in VS2005 on exe VS06 Pin
Chris Losinger27-May-10 6:17
professionalChris Losinger27-May-10 6:17 
QuestionRe: Problem loading dll compiled in VS2005 on exe VS06 Pin
David Crow27-May-10 6:27
David Crow27-May-10 6:27 
AnswerRe: Problem loading dll compiled in VS2005 on exe VS06 Pin
PrafullaShirke2727-May-10 21:41
professionalPrafullaShirke2727-May-10 21:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.