online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> // std::cout #include <algorithm> // std::shuffle #include <array> // std::array #include <random> // std::default_random_engine #include <chrono> // std::chrono::system_clock struct Card{ int value; enum Suit {spades, hearts, clubs, diamonds}; Suit suit; friend std::ostream& operator<<(std::ostream& os, const Card& card); }; std::ostream& operator<<(std::ostream& os, const Card& card){ switch(card.value){ case 11: os<<"Jack of "; break; case 12: os<<"Queen of "; break; case 13: os<<"King of "; break; case 1: os<<"Ace of "; break; default: os<<card.value<<" of "; break; } switch(card.suit){ case card.spades: os<<"Spades"; break; case card.hearts: os<<"Hearts"; break; case card.clubs: os<<"Clubs"; break; case card.diamonds: os<<"Diamonds"; } return os; } int main () { const size_t numCards = 52; std::array<Card, numCards> cards; for(size_t i=0; i<numCards; ++i){ cards[i].value=i%13+1; cards[i].suit=Card::Suit(i/13); } // obtain a time-based seed: unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); shuffle (cards.begin(), cards.end(), std::default_random_engine(seed)); std::cout << "shuffled elements:\n"; for (auto& x: cards) std::cout << x << '\n'; return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue