All pastes #923933 Raw Edit

Untitled

public text v1 · immutable
#923933 ·published 2008-02-29 23:27 UTC
rendered paste body
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
using namespace std;

#define V_SIZE 10	// #define the vector size here

int main() {
	
	// Create three vectors and allocate their size
	vector<int> u(V_SIZE);
	vector<int> v(V_SIZE);
	vector<int> w(V_SIZE);
	
	// Populate vectors u & v with integers
	for(int i = 0; i < V_SIZE; i++) {
    	u[i] = i;
		v[i] = i;
		w[i] = u[i] + v[i];
	}

	cout << "The first vector contains: ";
	// Print the contents of the vector
	for(int i = 0; i < u.size(); i++)
	    cout << u[i] << ", ";
	cout << endl;

	cout << "The second vector contains: ";
	// Print the contents of the vector
	for(int i = 0; i < v.size(); i++)
	    cout << v[i] << ", ";
	cout << endl;

	cout << "The third vector contains: ";
	// Print the contents of the vector
	for(int i = 0; i < w.size(); i++)
	   cout << w[i] << ", ";
	cout << endl;
 
	return 0;
}




#include <iostream>
#include <string>
#include <vector>
#include <fstream>
using namespace std;

int main() {
	
	// Create three vectors 
	vector<int> u;
	vector<int> v;
	vector<int> w;
	
	// Populate vectors u & v with integers
	for(int i = 0; i < 10; i++) {
    	u.push_back(i);
		v.push_back(i);
		w[i] = u[i] + v[i];
	}

	cout << "The first vector contains: ";
	// Print the contents of the vector
	for(int i = 0; i < u.size(); i++)
	    cout << u[i] << ", ";
	cout << endl;

	cout << "The second vector contains: ";
	// Print the contents of the vector
	for(int i = 0; i < v.size(); i++)
	    cout << v[i] << ", ";
	cout << endl;

	cout << "The third vector contains: ";
	// Print the contents of the vector
	for(int i = 0; i < w.size(); i++)
	   cout << w[i] << ", ";
	cout << endl;
 
	return 0;
}