Posts
 
Reputation
Joined
Last Seen
Ranked #3K
Strength to Increase Rep
+0
Strength to Decrease Rep
-0
20% Quality Score
Upvotes Received
1
Posts with Upvotes
1
Upvoting Members
1
Downvotes Received
5
Posts with Downvotes
5
Downvoting Members
3
4 Commented Posts
~2K People Reached
Favorite Tags
c++ x 16

10 Posted Topics

Member Avatar for Chalson

[QUOTE=elsiekins;1362228]Maybe use a array to store the variables , then sort the array in numerical order then access the first and last element of the array.[/QUOTE] There are only 20 numbers. It's faster to linear search while saving the biggest and smallest as you go: [code] #include <iostream> #include <cstdlib> …

Member Avatar for PsychoLogic
0
201
Member Avatar for techie1991

boolalpha and noboolalpha work for cin too: [code] #include <iostream> using namespace std; int main() { bool awesome = false; cout << "Are you awesome? "; if (!(cin >> boolalpha >> awesome)) { cin.clear(); cin >> noboolalpha >> awesome; } if (awesome) cout << "You *are* awesome!" << endl; else …

Member Avatar for techie1991
0
229
Member Avatar for rpdm

How can this BST class be better? [code] #include <iostream> #include <iomanip> #include <stdlib.h> #include <time.h> #include <conio.h> using namespace std; template <class KeyType, class ValueType> class BST { public: BST(): mroot(0), mcount(0) {} BST(BST const& tree) { *this = clone(tree.mroot); } BST& operator=(BST const& tree) { if (this != …

Member Avatar for alwaysLearning0
-1
112
Member Avatar for bmos31

Just for division: [code] template<typename T> T reduceArray(T myArray[], int size) { if (size == 0) return myArray[0]; return reduceArray(myArray, size - 1) / myArray[size]; } [/code]

Member Avatar for bmos31
0
226
Member Avatar for kc12286
Member Avatar for realproskater

To me it makes more sense to start from the current index and add the previous 2: [code] #include <iostream> using namespace std; int main() { int a[128] = {1, 1}; int terms; cout << "How many n terms do you want in the sequence: "; cin >> terms; for …

Member Avatar for kes166
0
133
Member Avatar for vbx_wx

Local variables are destroyed when the function returns. If you need a reference, you also need a different place to store the string so that it has a longer lifetime.

Member Avatar for Ketsuekiame
0
109
Member Avatar for 0pawix

Wrap the game in a loop. It's easier if the game is in a different function from main: [code] #include <iostream> #include <ctype.h> #include <conio.h> using namespace std; void play_game() { cout << "Playing game..." << endl; } int main() { do { play_game(); cout << "Again? (y/n)> " << …

Member Avatar for rpdm
0
128
Member Avatar for Tahir33

[QUOTE=Tahir33;1361612]no there're 7 [possible steps for 4 step tower.[/QUOTE] The problem definition is vague, but let's say the rules are like this: [list] [*]Step 0 can't be skipped [*]At any step, the next step can skipped [*]Only one step can be skipped at a time [*]The last step can't be …

Member Avatar for Tahir33
-3
206
Member Avatar for gerard4143

Pass by const reference if you want to accept literals: [code] myc(myc const& a, myc const& b):itsvalue(a.itsvalue + b.itsvalue) {} [/code]

Member Avatar for gerard4143
0
119

The End.