The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled C++ Code
Posted by: dopiwan | December 4, 2008 @ 1:12pm
C++ Code
[
Download
]
// thanks to DRobbins at katazeev #include <iostream> #include <cstdlib> #include <string> #include <time.h> using namespace std; int main() { //char myLyne[100]; //cin.getline(myLyne,100); string cardsuits[4] = { "Spades", "Hearts", "Diamonds", "Clubs" }; string cardfacesvalues[13] = { "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace" }; int deck [52]; int index; int newIndex; int holdVal; int crdsuit; int crdval; int holdIndex; int playerdecks[2][52]; int playerdptr[2]={0,0}; int playerrecoverys[2][52]; int playerdrptr[2]={0,0}; int playerindex; srand ( time(NULL) ); for(index=0; index <= 51; index++) { deck[index]=index; } for(index=0; index <= 51; index++) { newIndex = rand() % 52; holdVal = deck[newIndex]; deck[newIndex] = deck[index]; deck[index] = holdVal; } for(index=0; index <= 51; index++) { crdsuit=deck[index]/13; crdval=deck[index]%13; cout << "Card in Deck is: Index #" << index << ", Card # " << deck[index] << ", a " << cardfacesvalues[crdval] << " of " << cardsuits[crdsuit] << ", worth " << crdval << "\n"; } index=0; for(playerindex=0; playerindex <= 1; playerindex++) { for(newIndex=0; newIndex <= 25; newIndex++) { playerdecks[playerindex][newIndex] = deck[index]; cout << "index: " << index << ", playerindex: " << playerindex << ", newIndex: " << newIndex << ", Val: " << playerdecks[playerindex][newIndex] << "\n"; index++; } playerdptr[playerindex]=26; } char myLine[100]; cin.getline(myLine,100); return 0; }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.87 / 8
387 Votes
http://codebin.yi.org/199
page generated in 0.01 seconds