No errors just weird results from rand

I can't seem to get the right results for the program. It's a random and you press d to deal again and x to get out of the loop. Help is appreciated, thank you.


//Seventh Period Computer Science II
//Assignment #6 Due Date- November 16, 2012
//
//Problem Statement - The programmer has to make a program that prints out 10
//random cards and the user can play again if you would like, forever.
//
//Description of Algorithm-
//
//
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <iomanip>
#include <cstdlib>
#include <cmath.>
using namespace std;
void this_get_stuff(int &THIS_DECIDES_TYPE1, int &THIS_DECIDES_TYPE2,int &THIS_DECIDES_VALUE1, int &THIS_DECIDES_VALUE2, int &THIS_DECIDES_NUMBER1,int &THIS_DECIDES_NUMBER2, int value); // this is a function
void Lots_Of_Code (string &type1, string &type2, int &THIS_DECIDES_TYPE1, int &THIS_DECIDES_TYPE2, int &THIS_DECIDES_NUMBER1, int &THIS_DECIDES_NUMBER2, char &deal_or_no_deal, string &card1, string &card2); // heading and it calls
int main(int argc, char *argv[])
{ int THIS_DECIDES_TYPE1, THIS_DECIDES_VALUE2, THIS_DECIDES_TOTAL_VALUE, THIS_DECIDES_TYPE2, THIS_DECIDES_VALUE1, THIS_DECIDES_NUMBER1, THIS_DECIDES_NUMBER2, value;
char deal_or_no_deal = 'd';
int Round = 1;
string type1, type2, card1, card2;
while (deal_or_no_deal == 'd')
{
cout << "Player 1 :" << setw(40) << card1 << " and " << card2 << " Value:" << value << endl;
cout << "Player 2 :" << setw(40) << card1 << " and " << card2 << " Value:" << value << endl;
cout << "Player 3 :" << setw(40) << card1 << " and " << card2 << " Value:" << value << endl;
cout << "Player 4 :" << setw(40) << card1 << " and " << card2 << " Value:" << value << endl;
cout << "Player 5 :" << setw(40) << card1 << " and " << card2 << " Value:" << value << endl; // this is cout statements
cout << "Deal again or end (d or x)";
cin >> deal_or_no_deal;
system ("cls");
Round= Round + 1;
cout << "Round" << Round << endl;
}
this_get_stuff( THIS_DECIDES_TYPE1, THIS_DECIDES_TYPE2, THIS_DECIDES_VALUE1, THIS_DECIDES_VALUE2, THIS_DECIDES_NUMBER1, THIS_DECIDES_NUMBER2, value);
Lots_Of_Code( type1, type2, THIS_DECIDES_TYPE1, THIS_DECIDES_TYPE2, THIS_DECIDES_NUMBER1, THIS_DECIDES_NUMBER2, deal_or_no_deal, card1, card2);
// these fucntions are here to call them back to the main function
srand(time(NULL)); // this is so that ....
system("PAUSE");
return 0;
}
void this_get_stuff (int &THIS_DECIDES_TYPE1, int &THIS_DECIDES_TYPE2, int &THIS_DECIDES_VALUE1, int &THIS_DECIDES_VALUE2, int &THIS_DECIDES_NUMBER1, int &THIS_DECIDES_NUMBER2, int value )
{
THIS_DECIDES_TYPE1 = rand()% 4 + 1; // this is random for the type of card
THIS_DECIDES_TYPE2 = rand()% 4 + 1; // because there are 4 types
THIS_DECIDES_NUMBER1 = rand()% 13 + 1; // this decides the number
THIS_DECIDES_NUMBER2 = rand()% 13 + 1; // because there are 13 numbers in a deck
THIS_DECIDES_VALUE1 = THIS_DECIDES_TYPE1 + THIS_DECIDES_TYPE1;
THIS_DECIDES_VALUE2 = THIS_DECIDES_TYPE2 + THIS_DECIDES_TYPE2;
value = THIS_DECIDES_VALUE1 + THIS_DECIDES_VALUE2;
}
void Lots_Of_Code (string &type1, string &type2, int &THIS_DECIDES_TYPE1, int &THIS_DECIDES_TYPE2, int &THIS_DECIDES_NUMBER1, int &THIS_DECIDES_NUMBER2, char &deal_or_no_deal, string &card1, string &card2)
{
{if ( THIS_DECIDES_TYPE1 == 1)
type1 = " spades";
else if (THIS_DECIDES_TYPE1 ==2)
type1 = " hearts";
else if (THIS_DECIDES_TYPE1 ==3)
type1 = " clubs";
else
type1 = " diamonds";

if (THIS_DECIDES_TYPE2==1)
type2 = " spades";
else if (THIS_DECIDES_TYPE2==2)
type2 = " hearts";
else if (THIS_DECIDES_TYPE1==3)
type2 = " clubs";
else
type2 = " diamonds"; // this find the random type it is for type 2

if (THIS_DECIDES_NUMBER1 ==1)
card1 = " ace of";
else if (THIS_DECIDES_NUMBER1 ==2)
card1 = " two of";
else if (THIS_DECIDES_NUMBER1 ==3 )
card1 = " three of";
else if (THIS_DECIDES_NUMBER1 ==4 )
card1 = " four of";
else if (THIS_DECIDES_NUMBER1 ==5 )
card1 = " five of";
else if (THIS_DECIDES_NUMBER1 ==6 )
card1 = " six of";
else if (THIS_DECIDES_NUMBER1 ==7 )
card1 = " seven of";
else if (THIS_DECIDES_NUMBER1 == 8)
card1 = "eight of";
else if (THIS_DECIDES_NUMBER1 == 9)
card1 = "nine of";
else if (THIS_DECIDES_NUMBER1 ==10 )
card1 = "ten of";
else if (THIS_DECIDES_NUMBER1 ==11 )
card1 = "jack of";
else if (THIS_DECIDES_NUMBER1 ==12 )
card1 = "queen of";
else
card1 = "king of";// this finds what number the random card is

if (THIS_DECIDES_NUMBER2 ==1)
card2 = " ace of";
else if (THIS_DECIDES_NUMBER2 ==2)
card2 = " two of";
else if (THIS_DECIDES_NUMBER2 ==3 )
card2 = " three of";
else if (THIS_DECIDES_NUMBER2 ==4 )
card2 = " four of";
else if (THIS_DECIDES_NUMBER2 ==5 )
card2 = " five of";
else if (THIS_DECIDES_NUMBER2 ==6 )
card2 = " six of";
else if (THIS_DECIDES_NUMBER2 ==7 )
card2 = " seven of";
else if (THIS_DECIDES_NUMBER2 == 8)
card2 = "eight of";
else if (THIS_DECIDES_NUMBER2 == 9)
card2 = "nine of";
else if (THIS_DECIDES_NUMBER2 ==10 )
card2 = "ten of";
else if (THIS_DECIDES_NUMBER2 ==11 )
card2 = "jack of";
else if (THIS_DECIDES_NUMBER2 ==12 )
card2 = "queen of";
else
card2 = "king of";}
// this finds the number of card2
}
Edit your post to use the code format for your code.
And I think the issue is that you are seeding the random number generator at the end of main(), after the program is already finished. >_>
Lol. void Lots_of_code

doom3 had ~609000 lines of code.
Topic archived. No new replies allowed.