Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- #include <sstream>
- using namespace std;
- int main(int argc, char *argv[])
- {
- srand (time(NULL));
- int times = 1;
- if (argc == 2)
- {
- stringstream ss(argv[1]);
- ss >> times;
- }
- else if (argc > 2)
- {
- cout << "Usage: " << argv[0] << " <number of coins to flip>" << endl;
- return 1;
- }
- else if (argc == 1)
- cout << "Using 1 coin to flip!" << endl;
- for (int i = 0; i < times; i++)
- cout << ((rand()%RAND_MAX)%2 == 1 ? "Heads" : "Tails") << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment