| |
Giygas learns the art of C++
Lightning |
|

Ignorance isn't stupidity but choosing to remain ignorant is
![Super Happy Heart Badge [*]](https://archive.mfgg.net/html/badges/shappyheart.gif) ![MFGG Awards 2008 Winner [*]](https://archive.mfgg.net/html/badges/award08.gif)

Group: IRC Operators
Posts: 6381
Member No.: 583
Joined: 31-August 04
Status: (0d)
![[--]](style_images/mfgg2_skin/warn_nosuspend.gif)

|
a=a^b; b=a^b; a=a^b;
pretty sure you copied this from somewhere. it works for integers, granted, but can you explain why? also, you never use c. the method you explained in english is exactly correct though.
This post has been edited by Lightning on Sep 25 2009, 01:56 PM
--------------------
click here to change my avatar. / gosh why are you even here lightninghacker, n.an individual who enjoys learning computer system details and how to capitalize on his or her capabilities...not a criminal. (from webster's new world hacker dictionary) |  Fedora 10 Final! Download today! | quality web comics (stories):- girl genius: adventure! romance! mad science!
- punch an' pie: try a slice of life, then swallow.
- dresden codak: most interesting comic ever
quality web comics (one-shots):- a softer world: truth and beauty bombs
- smbc: saturday morning breakfast cereal
- buttersafe: pictures and probably some words
|
"Religion is comparable to a childhood neurosis." - Sigmund Freud “It is not by delusion, however exalted, that mankind can prosper, but only by unswerving courage in the pursuit of truth.” - Bertrand Russell “To kill an error is as good a service as, and sometimes better than, the establishing of a new truth or fact.” - Charles Darwin
|
|
|
Giygas |
|

Standard Member
![Happy Heart Badge [*]](https://archive.mfgg.net/html/badges/happyheart.gif)

Group: Members
Posts: 910
Member No.: 4767
Joined: 24-November 07
Status: (0d)
![[--]](style_images/mfgg2_skin/warn_nosuspend.gif)

|
Woah.
This one took a bit of thinking! After what Retro said about only needing one temp, I was wondering how I was going to program this to adapt to each card change. Then, of course, it hit me- Use a variabe that increases by 1 every time a new card is shown! This way, when it calls up Card[1], the variable will increase by one. So it will call up Card[2] the next time!
Then, of course, is the part where I needed to make it random. The part int t=card[i];card[i]=card[e];card[e]=t; shows me switching the variables using the previously described manor, but how was I going to make I random? Then it hit me- set a range of the numbers and subtract it by the same number that makes the array go in order. This way, all of the numbers go in order of the array- But they go at random now!
After all of this, I came up with this:
| QUOTE | #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int card[52]; int e; int main() { srand(time(0)); for(int i=0;i<52;i++) { card[i]=i; } shuffle: { for(int i=0;i<(52-1);i++) { int e=i+(rand()%(52-i)); int t=card[i];card[i]=card[e];card[e]=t; } for(int c=0;c<52; c++) { cout <<card[c]<<", "; } cout <<endl; cout << "\nCard's Shuffled! Shuffle again?\n\n\n"; } system("pause"); goto shuffle; return 0; }
|
Did I pass :D?
|
|
|
Xgoff |
|

<):|
![Super Happy Heart Badge [*]](https://archive.mfgg.net/html/badges/shappyheart.gif) ![Sprite Comp Winner Badge (1) [*]](https://archive.mfgg.net/html/badges/scg1.gif) ![Drawing Comp Winner Badge (1) [*]](https://archive.mfgg.net/html/badges/dcg1.gif) ![Drawing Comp Runner Up Badge (1) [*]](https://archive.mfgg.net/html/badges/dcr1.gif) ![MFGG Awards 2006 Winner [*]](https://archive.mfgg.net/html/badges/award06.gif)
![MFGG Awards 2007 Winner [*]](https://archive.mfgg.net/html/badges/award07.gif) ![Forum Event Badge [*]](https://archive.mfgg.net/html/badges/event.gif)

Group: Members
Posts: 52341
Member No.: 24
Joined: 13-October 03
Status: (0d)
![[--]](style_images/mfgg2_skin/warn_nosuspend.gif)

|
| QUOTE (Giygas @ Sep 27 2009, 03:08 PM) | Think i'm going to let off the arrays, and move onto uh Whatever comes next!~ *checks* Character Sequences. Hmm. Looks good :3 |
character sequences are arrays
unless i'm thinking of something totally different
--------------------
 DISCLAIMER: by sending me (xgoff) a private message, you agree to the directives and their terms specified henceforth: DIRECTIVE 1 (APPLE): i may or may not reply promptly or at all; and there are no guarantees to the usefulness of the reply. i may not acknowledge whether i have even received your private message DIRECTIVE 2 (CHILE CON CARNE): as per my view, "private" applies only to the initial transaction, and the material of your message may or may not be made public at my discretion; as this will more than likely be a post in the CCC or IRC, you may not be able to view it DIRECTIVE 3 (FEATHER DUSTER): you must address me (xgoff) as "Sir Master Xgofficus his Highest and Most Awesome the Third"; failure to comply with this term may invoke one or both of the above directives, and i will leave a burning bag of **** on your doorstep DIRECTIVE 4 (BOOTSTRAP): if you have read this disclaimer, please private message me promptly, in compliance with the above terms, so i can ensure you are capable of following directions you idiot this concludes the test of the emergency disclaimer system, your scheduled programming will now continue. satisfaction guaranteed, and 100% cash back available under certain circumstances; restrictions may or may not apply within your place of residence NOTICE: these directives and their terms may change at any time, without notice; as a private message transaction to myself assumes an understanding and full compliance of the above, you should ensure you are fully aware of the above terms at any point before sending a private message; any message received is assumed to have been sent in compliance with the above| QUOTE | (5:25:58 PM) Mikau: xgoff (5:26:00 PM) Mikau: guess what (5:26:04 PM) Xgoff: chicken butt (5:26:09 PM) Mikau: **** you |
|
|
|
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
Track this topic
Receive email notification when a reply has been made to this topic and you are not active on the board.
Subscribe to this forum
Receive email notification when a new topic is posted in this forum and you are not active on the board.
Download / Print this Topic
Download this topic in different formats or view a printer friendly version.
[ Script Execution time: 0.1157 ] [ 13 queries used ] [ GZIP Enabled ] [ Server Load: 1.15 ]
| |