Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>//
- #include <ctime>//needed to seed random function
- using namespace std;
- char randomiser(unsigned long long int randTotal)
- {
- cout << randTotal << " recieved as input" <<endl;
- srand(time(NULL));
- unsigned long long int randomNum;//random integer 0-3
- char randChar;//random character A, T, C or G
- for(long long int randIndex = 1; randIndex<=randTotal; randIndex++)
- {
- randomNum = rand() %4;
- switch(randomNum)
- {
- case 0:
- randChar = 'A';
- break;
- case 1:
- randChar = 'T';
- break;
- case 2:
- randChar = 'G';
- break;
- case 3:
- randChar = 'C';
- break;
- default:
- cout << "error!" << endl;
- break;
- }
- cout << randIndex << " " << randomNum << " " << randChar << endl;
- }
- return randChar;
- }
- int main()
- {
- unsigned long long int randTotal;//unsigned means can only store positive or zero values
- cout << "How many random characters do you want to generate?" << endl;
- cin >> randTotal;
- randomiser(randTotal);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement