// War Card Game! (Build 15w30)
// This is is a player vs. cpu simulatation.
// The player will press space to place the
// next card down. The side with the higher
// card of the two wins the round. First one
// to have a full deck wins! (2 low - A high)
#include <iostream>
#include <algorithm>
#include <array>
#include <random>
#include <chrono>
float cards[52];
float collectDeck() //finds full deck.
{
int i = 0; // Counter
int c = 1; // Number of the Card
int s = .1;// Suit of the Card
while(i < 52) // Makes sure only 52 cards are ran.
{
if(c == 13) // If a full suit is counted.
{
c = 0;
s = s + .1;
}
cards[i] = (c+s);
c++;
i++;
}
return (cards);
}
float shuffleCards ()
{
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
shuffle (cards.begin(), cards.end(), std::default_random_engine(seed));
std::cout << "Shuffled Cards:";
for (int& x: foo) std::cout << ' ' << x;
std::cout << '\n';
return (cards);
}
int main ()
{
collectDeck();
shuffleCards();
return 0;
}
You are declaring a C-style array as a global, float cards[52];, and using STL container iterators on that global.
Since you already have your card set at global scope why the need to declare a return type on your functions? Your cards[] array has global scope, visible everywhere.