Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <climits>
- #include <random>
- void randomStream(std::string &fileName, int &length);
- int main()
- {
- std::string fileName;
- int length;
- std::cout << "Please input a filename:" << std::endl;
- std::cin >> fileName;
- std::cout << "How many iterations:" << std::endl;
- std::cin >> length;
- randomStream(fileName, length);
- return 0;
- }
- void randomStream(std::string &fileName, int &length)
- {
- std::ofstream outFile;
- outFile.open(fileName);
- if (outFile)
- {
- std::random_device rd;
- std::mt19937 gen(rd());
- std::uniform_int_distribution<> dis(0, 5);
- for (int i = 0; i < length; ++i)
- {
- int randNum = dis(gen);
- if (randNum == 1){
- std::uniform_int_distribution<> dis(INT_MIN, INT_MAX);
- int minMax = dis(gen);
- outFile << "A " << minMax << std::endl;
- }
- else if (randNum == 2){
- outFile << "D" << std::endl;
- }
- else if (randNum == 3){
- outFile << "P" << std::endl;
- }
- else if (randNum == 4) {
- outFile << "E" << std::endl;
- }
- else if (randNum == 5) {
- outFile << "C" << std::endl;
- }
- else {
- outFile << "S" << std::endl;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement