// bsp5b.cpp : Summe von 1 bis 100, Reduktion
#include "stdafx.h"
#include <omp.h>

using namespace System;

int main(array<System::String ^> ^args)  {
	const int MAXTHREADS=4;
	
	omp_set_num_threads(MAXTHREADS);
	int summe=0;	// Diesen Wert erhält jeder Thread, ā la copyprivate
	
	#pragma omp parallel for  reduction(+:summe)
		for (int i = 0; i < 10000; ++i) {
			//j=summe;
			//summe=j + i+1;
			summe+=i+1;
		}
		
	Console::WriteLine("Summe: {0}  ", summe );
	Console::ReadLine();

	return 0;
}
