Example #1
0
int main(int argc, char** argv) {
	std::vector<Person> people({
		{"a", {1901, 1950}},
		{"a", {1902, 1951}},
		{"a", {1909, 1912}},
		{"a", {1912, 1956}},
		{"b", {1932, 2010}},
		{"b", {1933, 2010}},
		{"b", {1934, 2035}},
		{"b", {1935, 2010}}
	});

	std::cout << compute(people) << std::endl;
	return 0;
}
Example #2
0
int main(int argc, char* argv[])
{
	size_t numberOfPeople = std::stoi(argv[1]);
	size_t numberOfSamples = std::stoi(argv[2]);

	std::atomic<size_t> countPointingPairs(0);
	
	std::uniform_int_distribution<int> distribution(0, numberOfPeople - 1);
	std::mt19937 engine;
	auto rand = std::bind(distribution,engine);
	
	tbb::task_group tg;
    
	for ( size_t i=0; i<numberOfSamples; ++i )
	{
  	tg.run([&]{
	std::vector<Person> people(numberOfPeople);
		for ( auto& person : people )
		{
			auto targetPerson = &people[rand()]; 
			while( targetPerson == &person )
			{     
				targetPerson = &people[rand()];  
			}
    	person.pointsTo = targetPerson;
		}
		
		for ( auto& person : people )
		{
    	if ( person.pointsTo->pointsTo == &person )
    	{
				++countPointingPairs;
				break;
			}
		}
	});};

	tg.wait();
	
	std::cout << (double)countPointingPairs / (double)numberOfSamples << std::endl;

	return 0;
}
Example #3
0
void image()
{int i;
 randomize();
 settextstyle(1,HORIZ_DIR,9);
 for (i=-250;i<10;i+=5)
 {setcolor(BLACK);
  outtextxy(i-5,0,*Title);// "Hyper"
  setcolor(LIGHTBLUE);
  outtextxy(i,0,*Title);// "Hyper"
  Delay(1);
 }
 Delay(300);
 setcolor(LIGHTRED);
 settextstyle(3,HORIZ_DIR,16);
 for (i=1;i<7;i++)
 {outtextxy(210+i*60,60,*(Title+i));// "Reader"
  Delay(400);
 }
 Delay(100);
 for (i=1;i<7;i++)
 {settextstyle(4,0,i);
  setcolor(LIGHTCYAN);
  outtextxy(450,190,*(Title+7));// "2000"
  Delay(300);
  setcolor(BLACK);
  settextstyle(4,HORIZ_DIR,i);
  outtextxy(450,190,*(Title+7));// "2000"
 }
 setcolor(LIGHTCYAN);
 settextstyle(4,HORIZ_DIR,i);
 outtextxy(450,190,*(Title+7));// "2000"
 Delay(400);
 setcolor(BLUE);
 line(10,140,250,140);
 line(250,140,250,200);
 line(250,200,400,200);
 line(400,200,400,280);
 line(400,280,600,280);
 Delay(800);
 setcolor(LIGHTGREEN);
 settextstyle(2,0,7);
 outtextxy(20,200,*(Title+8));// "Produced by Zhao Chang."
 Delay(500);
 outtextxy(40,225,*(Title+9));// "Copyright (C)  2000"
 Delay(500);
 outtextxy(37,250,*(Title+10));// "ALL RIGHTS RESERVED."
 Delay(500);
 setcolor(LIGHTMAGENTA);
 settextstyle(1,0,2);
 outtextxy(340,350,*(Title+11));// "Press any key . . ."
 setcolor(WHITE);
 settextstyle(2,0,5);
 outtextxy(142,450,"Version");
 outtextxy(205,450,Version);
 outtextxy(377,450,"Update:");
 outtextxy(435,450,Update);
 people();
 book();
 Delay(2000);
 ClearKey();
 while (!kbhit())
 {ChangeColor();
  book();
  people();
  delaykey(30);
 }
 getch();
 restorecrtmode();
}
Example #4
0
int main(int argc, char * argv[]) {
	people();
	things();
    return 0;
}