Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Exam.h"
- #include <iostream>
- #include <fstream>
- #include <ctime>
- using namespace std;
- void Exam::loadExam(){
- //seeds random function
- srand(time(NULL));
- //Loads the Exam key randomly
- for(int i=0;i<100;i++)
- {
- key[i][0] = rand()%5;
- bool distinct = false;
- while(!distinct)
- {
- key[i][1] = rand()%5;
- if(key[i][0]!=key[i][1])
- distinct = true;
- }
- }
- }
- void Exam::writeExam(int a){
- ofstream output;
- //Determine which test will be writen
- switch(a){
- case 1:
- output.open("Test A.txt");
- break;
- case 2:
- output.open("Test B.txt");
- break;
- case 3:
- output.open("Test C.txt");
- break;
- case 4:
- output.open("Test D.txt");
- break;
- }
- //Writes test to a file
- for(int i=0;i<100;i++)
- {
- output<<key[i][0]<<" "<<key[i][1]<<endl;
- }
- output.close();
- cout<<"done"<<endl;
- }
Add Comment
Please, Sign In to add comment