Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › C++/C Programming › For loop help

QuestionFor loop help

Posts 1–2 of 2 · Page 1 of 1
AN
ANONlMOUS
For loop help
Prompt:

1. generate 3 random numbers
2. add 1 to inside count if the second random number is greater than the first random number and less than the third random number
3. add 1 to outside count if the second random number is less first random number
4. add 1 to outside count if the second random number is greater than the third random number
5. add 1 to loop count.
repeat step 1 to 5 until inside count + outside count = maximum count using a for loop
the best solution uses 1 multi-way if statement with compound conditions to determine when to add 1 to inside count and outside count

My attempt:

#include <ctime>
#include <iomanip>
#include <iostream>
#include <random>
#include <string>
using namespace std;

int main()
{
const int ubound = 99;
const int lbound = 10;
uniform_int_distribution<int> u(lbound, ubound);
int seed = 0;
//int seed = (int)time(nullptr);
default_random_engine e(seed);

int outside_count = 0;
int inside_count = 0;
int loop_count = 0;
int max_count = u(e);
int n1, n2, n3;

while (inside_count + outside_count < max_count)
{
n1 = u(e);
n2 = u(e);
n3 = u(e);
loop_count++;
cout << setw(3) << loop_count << ": (" << n1 << ", " << n2
<< ", " << n3 << ") inside:" << setw(2) << inside_count << " outside: " << setw(2) << outside_count << endl;
for (n2 = u(e); (n2 > n1 && n2 < n3); inside_count = inside_count + 1)
{
//inside_count = inside_count + 1;
cout << inside_count << endl;
}

{
for (n2; ((n2 < n1) || (n2 > n3)); outside_count = outside_count + 1)
cout << outside_count << endl;
}
/*else if ((n2 < n1) || (n2 > n3))
{
outside_count = outside_count + 1;
cout << outside_count << endl;
}
/*else if (n2 > n3)
{
outside_count = outside_count + 1;
cout << outside_count<<endl;
}
*/
loop_count = loop_count + 1;
cout << outside_count << endl;
cout << max_count << endl;
cout << inside_count;


}

system("pause");
return 0;
}
Can someone please help me?
#1 · 7y ago
gogogokitty
gogogokitty
next time please put your code in the code tags.

im assuming your asking for something like this, everytime the program loops, n1/n2/n3 generate a random number for themselves, uses a for loop with if statements inside to determine the addition to the inside_count/outside_count, if those 2 numbers combined is greater than max_count then the loop will end.

Code:
#include <ctime>
#include <iomanip>
#include <iostream>
#include <random>
#include <string>
using namespace std;

int main()
{
	srand(time(NULL));//make a random seed(i think its called a seed)
	const int ubound = 99;//not needed
	const int lbound = 10;//not needed
	uniform_int_distribution<int> u(lbound, ubound);//not needed
	int seed = rand();//not needed
					  //int seed = (int)time(nullptr);//not needed
					  //default_random_engine e(seed);//not needed

	int outside_count = 0;
	int inside_count = 0;
	int loop_count = 0;
	int max_count = 100;
	int n1, n2, n3;

	cout << "maxCount: " << max_count << endl << endl;

	//run while inside_count + outside_count is less than max_count, increment loop_count on each run
	for (; inside_count + outside_count < max_count; loop_count++)
	{
		//get random numbers for n1/n2/n3 on each run
		n1 = rand();
		n2 = rand();
		n3 = rand();

		cout << setw(3) << loop_count << ": (n1: " << n1 << ", n2: " << n2
			<< ", n3: " << n3 << ") inside:" << setw(2) << inside_count << " outside: " << setw(2) << outside_count << endl << endl;

		if (n2 > n1 && n2 < n3)//if n2 is greater than n1 and less than n3 increment inside_count by 1
			inside_count += 1;
		if (n2 < n1)//if n2 is less than n1 increment outside_count by 1
			outside_count += 1;
		if (n2 > n3)//if n2 is greater than n3 increment outside_count by 1
			outside_count += 1;
	}

	system("pause");//with visual studio, press CTRL + F5 and the window will hold itself open without the need for this line
	return 0;
}
#2 · 7y ago
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Similar Threads

  • Help Me For Loop .By azamsadin in Blackshot Coding & Source Code
    8Last post 10y ago
  • [HELP]"for" loopBy Drake in C++/C Programming
    4Last post 15y ago
  • Looking for Serious HelpBy kittens4life in Combat Arms Coding Help & Discussion
    5Last post 13y ago
  • aim assist for pblackout help plsBy bigx270 in Piercing Blow Help
    0Last post 14y ago
  • PLZ im dying for your helpBy ihack4 in CrossFire Help
    3Last post 15y ago

Tags for this Thread

#noob