rendered paste body#include <iostream>
#include <time.h>
using namespace std;
int checkfirst(int total) {
//Checks the first roll for winning, losing, and find the point
if(total==7) {
cout << "\nWIN!";
return(1);
} else if(total==2||total==3||total==12) {
cout << "\nLOSE!";
return(1);
} else {
cout << "Point:" << total << "\n";
return(0);
}
}
int checkwin(int total, int point) {
//Checks to see if you win or lose
if(total==7) {
cout << "\nLOSE!";
return(1);
} else if(total==point) {
cout << "\nWIN!";
return(1);
} else {
return(0);
}
}
void roll(int& die, int& prev) {
//Because you said so
int localprev=prev;
srand(time(NULL)+die);
die=(rand()%6+1)+(rand()%6+1);
if(die==localprev) {
srand(time(NULL)+die+localprev+rand());
die=(rand()%6+1)+(rand()%6+1);
}
prev=die;
}
int main() {
//Does everything else
srand(time(NULL));
int total=(rand()%6+1)+(rand()%6+1);int point=total;int prev=total;int win,temp;
cout << "Rolled:" << total << endl;
if(checkfirst(point)==1) return(0);
cout << "#################################\n";
while(win!=1) {
roll(total,prev);
cout << "Rolled:" << total << endl;
win=checkwin(total, point);
}
}