Sutekh's C++ +More Thread

  • Guest, it's time once again for the massively important and exciting FoH Asshat Tournament!



    Go here and give us your nominations!
    Who's been the biggest Asshat in the last year? Give us your worst ones!

Evernothing

Bronze Baronet of the Realm
4,824
9,028
anigif_enhanced-buzz-14091-1389700869-1.gif
 

Tuco

I got Tuco'd!
<Gold Donor>
47,825
82,253
Swap the value of these two variables without using a third variable

int main()
{

int a = 42;
int b = 7;

return 0;
}
 

Adebisi

Clump of Cells
<Silver Donator>
27,735
32,840
Stop pretending like you got something better to do on your friday night!
 

Tuco

I got Tuco'd!
<Gold Donor>
47,825
82,253
int main()
{

int foo [5] = { 16, 2, 77, 40, 12071 };

return 0;
}

sort it!
 

Wuyley_sl

shitlord
1,443
13
Dear god I just wasted 30 seconds of my life looking at this thread that I will never get back. Thank you for that. Now off to Redtube to spend some quality time.
 

Tuco

I got Tuco'd!
<Gold Donor>
47,825
82,253
Stop pretending like you got something better to do on your friday night!
Help me out bro. I have a 2d array that represents obstacles (or threat level) of an environment for a robot. The orientation of the world is constant. I need to display those obstacles to the user such that the orientation of the robot is constant (and the world rotates and moves around the robot). So I need to take my existing 2d array and rotate it by some arbitrary angle centered around some arbitrary point.

Fix this code so it's faster and doesn't have any holes. Current output:

 

Adebisi

Clump of Cells
<Silver Donator>
27,735
32,840
I'm only in the newbie zone killing little spiders and gathering crates.

I must've set the difficulty too high

rrr_img_58560.jpg
 

LennyLenard_sl

shitlord
195
1
I'm never sure if anyone is serious around here, but if you are legitimately looking for a solution Tuco, here's a shot.

First, unwind your loops. That usually can save you time. From my experiences it's faster to calc x and y each iteration in a single loop than multi looping.

I'm not C/C++ wiz, so I can't give you much more than that.

As for filling your holes, you're going to have to do some checks (and average neighbors) since you don't want edges to wrap around to the other side. You can even do diagonal neighbors if you want to get crazy. Someone else can probably give you better advice how to speed this up.

Output:
 

Sir Funk

Molten Core Raider
1,251
155
Let's make a Tic-Tac-Toe game!

Let's start from here:
Starting with the above, let's populate our board array with whatever random X's and O's you like and then write a function PrintBoard() that will output the current state of the board.
 

LennyLenard_sl

shitlord
195
1
What about me? What about Adebisi's beginner challenges?
Calculate a chick's real height and weight.

Input should be in Internet inches, weight in Internet lbs.

Real inches = Internet inches * 0.98
Real lbs = Internet lbs * 1.25

cm = inch * 2.54
kg = lb * 2.2

Output in real inches and lbs as well as cm and kg
 

Adebisi

Clump of Cells
<Silver Donator>
27,735
32,840
Challenge Accepted
rrr_img_58677.jpg


(PS I watch all of Attack on Titan in one sitting today)