C++ :: Simple Playing Card Deck Creator And Shuffler
Aug 10, 2014
This is a playing card deck creator and shuffler i made yesterday. It is very simple now, but i believe that it could easily be implemented into a card game program of some sort.
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <ctime>
#define STANDARD_DECK 52
[Code] .....
View 1 Replies
ADVERTISEMENT
Oct 22, 2014
Write a program to simulate a deck of 52 playing cards.
Represent your deck as a 2D Array where the value in the cell is the position of the card in the deck. Represent the names for the suits and faces as an array of Strings.
Write an algorithm to shuffle the deck.
Display the deck. For Example:
1 Jack of Spades
2 Deuce of Diamonds
3 Three of Diamonds
4 King of Spades
5 Eight of Clubs
6 King of Diamonds
7 Six of Clubs
8 Six of Spades
9 Eight of Hearts
Deal two hands of five cards each. For Example:
****** HAND 1 ******
Jack of Spades
Three of Diamonds
Eight of Clubs
Six of Clubs
Eight of Hearts
...
Below is what I have so far. Dealing two hands and displaying it. How would I be able to do that?
#include <iostream>
#include <ctime>
#include <string>
using namespace std;
void shuffle(int[][2]);
int main()
{
int j,deck[52][2];
[Code]...
View 2 Replies
View Related
Oct 26, 2014
Write a program to simulate a deck of 52 playing cards.
Represent your deck as a 2D Array where the value in the cell is the position of the card in the deck.
Represent the names for the suits and faces as an array of Strings.
#include "stdafx.h"
#include <iostream>
#include <string>
[Code].....
The problem: I am trying to connect the 1d arrays to the 2d arrays. Right now when I write: cout << deck[3][5] << endl; The output answer is 45. How do I populate the 2d array with the 1d arrays so that when I cout deck[3][5] I get it to say "Six of Spades"?
View 8 Replies
View Related
Mar 25, 2014
The deck of cards so it is populated with all 52 cards. Once you have populated the deck, you need to shuffle the deck. Here is a simple algorithm you might consider for this purpose:
For each card up to the middle of the deck generate a random number modulus the size of the deck, swap the current card with the card at that location done
To implement this requirement you need to implement and use the following functions:
void initDeck(Card * deck);
View 4 Replies
View Related
Jan 23, 2015
I am trying to link OpenCV to my qt project, but for some reason it doesn't seem to able to find my files. my .pro file looks like this
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = opens
TEMPLATE = app
INCLUDEPATH += /usr/local/include
HEADERS += mainwindow.h
LIBS += -lm -lopencv_core -lopencv_highgui -lopencv_video -lopencv_imgproc
SOURCES += main.cpp
mainwindow.cpp
FORMS += mainwindow.ui
I get the error message saying library not found for -lopencv_core and it is the same for the other ones.
I've been following this guide : [URL]
What is going on?
View 4 Replies
View Related
Dec 16, 2013
this programm should in theory create a labyrinth but it doesnt and i really dont have the skill to pick up where i have been mistaken so gcc runs it but it crashes and it doesnt produce any remarkable results even when it runs....
for example this should you run it with these parameters .
5
5
appear something like this
10111
10101
10101
10001
11111
or like this
10111
10001
11101
10001
11111
but it only crashes....it works with recursion and it makes a array (which is Ptr) a set of 1 and 0 which 0 is the path and 1 is the walls...
Code:
#include <stdio.h>#include <stdlib.h>
#include <time.h>
int **Ptr;
int M, N, P, charge, i,c,j;
void Lab_creator(int vertical, int horizontal,int direction);
[Code] .....
View 2 Replies
View Related
Mar 19, 2014
I am using Qt Creator with VS2012 compiler.
I declared a QByteArray variable : T
I initialized it. Everything OK. I added the line :
Code:
T += "
";
What follows gives me an exception and I think that the issue comes from this added line. As I take a look at T in the debugger, I don't see any but a point .
View 8 Replies
View Related
Nov 24, 2014
I am trying to create an expression creator that prints the work out too, not just the answer.
Code:
#include <iostream>
#include <windows.h>
using namespace std;
void p1();
void p2();
void p3();
double P,P2,p,ans,ans2,ans1,restart;
[Code] .....
View 4 Replies
View Related
Apr 12, 2014
I am using PDF Creator printer to print my files. I have set it as default printer. It displays two dialogs .. "Printer Setup Dialog" and "Dialog asking filename and other details to save to file".
I want to avoid these two dialogs. But EndDoc calls the other dialog by default. How to do this ?
View 13 Replies
View Related
Mar 5, 2013
I'm still new at C++, so my syntax might be a little off for getting the correct output. Currently, there are no compiler errors or warnings, but there is also no output when I run the program. It seems as if it is not calling something correctly maybe the .toString or perhaps my DeckOfCards constructor is a little off, either way, I can't seem to figure out why there is no output.
Anyways, here is my code:
Card.h
#ifndef CARD_H
#define CARD_H
#include <string>
using namespace std;
class Card {
[Code] ....
View 3 Replies
View Related
Sep 9, 2013
Here is my source code i am trying to write a function (fillAll) to fill all 52 cards in a deck and i would like to use my data struct for the function and make Deck one of my parameters.
enum suit{HEARTS, CLUBS, DIAMONDS, SPADES};
enum face{TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE};
struct Card{
suit suitType;
face faceType;
[Code] .....
View 10 Replies
View Related
Feb 6, 2014
How to make a standard deck of cards and being able to shuffle and distribute the cards. I have made an array to store each card and I can display them but I assigned them all in order according to the suit and rank. Is this a viable way to do it if I intend to have a shuffle effect? Or should I create an array, randomly generate card, check for duplicates, then put them in the array, then display the array? Each card is a structure with two void pointer members for suit and rank.
View 1 Replies
View Related
Sep 9, 2013
I have a deck of 108 cards inside a 2D array and want to deal these card by 7 to 4 player. Each player had a id. The player and id are stored in a file while i've read in array each. Now I have to deal the cards.
Code:
struct card{
char color;
int rank;
char action[24];
char location[108]; Code: struct players{char name[10];
int id[5];
char hand;
};
View 2 Replies
View Related
Jan 24, 2013
The music that I want to plays not run :( Theoretically all arguments are well, but I don't understand why not works.
if(Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 4096) < 0) {
cout << "Error inesperado";
return 0;
}
Mix_Init(0);
Mix_Music *musica = NULL;
musica = Mix_LoadMUS("pixeluniverse.wav");
if (!Mix_PlayMusic(musica, -1)) {
cout << "Error inesperado";
}
...
View 12 Replies
View Related
Nov 27, 2014
I'm trying to sort a deck from file with merge sort.I have all my code working except merge sort function .
#include<iostream>
#include<fstream>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int temp;
int br = 1;
[Code] ....
View 10 Replies
View Related
Jan 5, 2013
i have a audio file that i want to play via C+.
View 4 Replies
View Related
Apr 4, 2014
I tried playing audio using irrKlang in openGL.But i ended up with some problems.
I have attach my source file and also my output file here.
View 2 Replies
View Related
May 21, 2014
I am writing a console application that creates a shuffled deck of cards using pointers and arrays, but I get the error "Run-Time Check Failure #2 - Stack around the variable 'deck' was corrupted" What's the stack? What does this mean and what did I do to cause the stack to be corrupt?
#define _CRT_SECURE_NO_WARNINGS
#include "stdlib.h"
#include "time.h"
#include "stdio.h"
#include "conio.h"
typedef struct card{
int cval;
[Code] .....
View 8 Replies
View Related
Apr 2, 2014
My assignment is to create a program to print a deck of 52 cards, shuffle it, deal 2 hands of 5 cards, then print the deck after dealing the 2 hands with the cards that were dealt removed. this is my code so far...
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define DECK_SIZE 52
void init_deck( int deck[] , int size ) ;
void shuffle_deck( int deck[] , int size ) ;
[Code] ....
I am having trouble dealing 2 random hands and how to print the deck with the cards removed.
View 3 Replies
View Related
Aug 8, 2013
I'm thinking of making a horror text-based game, which would use sounds, if you could also tell me of an API to display images in an alternate window that would be nice.
View 6 Replies
View Related
Apr 9, 2014
I am making a game of quiz and i want to play a small clip in one of the rounds, but i dont know how to do it in c++ ....
View 3 Replies
View Related
Mar 26, 2014
I try to play a video I i don't know how.. I searched and i found some tips and articles, but all of it if about Windows Media Player. It's fine, but i need to play something lika an intro an i don't wanna show all that buttons of WMP.. I tried to hide it but no change.
View 2 Replies
View Related
Apr 26, 2013
I can not get the sound to stop playing a cda file with MCI_CLOSE. This code works with wav and mpg and avi files.
LONG WindowProc() {
switch (msg) {
case WM_COMMAND:
if (wParam == IDC_PLAY) {
//A CDA File
SendMessage(m_hwMCI,MCIWNDM_OPENA,0,(LPARAM)&chFile);
[Code] .....
View 1 Replies
View Related
Dec 15, 2014
How does one go about Playing a music file that they picked and playing it in the default player?
I already have this:
#include <iostream>
#include <windows.h>
using namespace std;
int main(){
string wavfile = "C:Documents and SettingsJasonMy DocumentsJasonMy MusicDummy.wav";
[Code] ....
View 5 Replies
View Related
Oct 25, 2013
I am developing a VC++ application with windows media player component. play video from a video buffer data which i have?
View 2 Replies
View Related
Sep 9, 2013
i was reading trying to get it how to display the out put, all i got to is how to declare the arrays. How to start it also i saw some examples have " struct card"
the display should look like this:
2c 2h 2s 2d
3c 3h 3s 3d
4c 4h 4s 4d
5c 5h 5s 5d
6c 6h 6s 6d
7c 7h 7s 7d
8c 8h 8s 8d
9c 9h 9s 9d
10c 10h 10s 10d
Jc Jh Js Jd
Qc Qh Qs Qd
Kc Kh Ks Kd
Ac Ah As Ad
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int deck [13][4];
string suits [4] = {"h", "d","c","s"};
string values [13] = { "2", "3", "4", "5","6", "7"," 8" ,"9", "10"," J", "Q"," K" , "A"};
system ("pause");
return (0);
}
View 2 Replies
View Related