I am working on a dice rolling game, is there any way I can implant a high score into this code?
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
int main() {
while(1==1){
srand(time(0));
int dice1,dice2,dice3,ddice1,ddice2,ddice3,dddice1,dddice2,dddice3;
for(int y=0;y<3;y++){
if(y==0)dice1=rand()%6+1;
if(y==1)dice2=rand()%6+1;
if(y==2)dice3=rand()%6+1;
}
for(int y=0;y<3;y++){
if(y==0)ddice1=rand()%6+1;
if(y==1)ddice2=rand()%6+1;
if(y==2)ddice3=rand()%6+1;
}
for(int y=0;y<3;y++){
if(y==0)dddice1=rand()%6+1;
if(y==1)dddice2=rand()%6+1;
if(y==2)dddice3=rand()%6+1;
}
cout<<"This is a game of rolling 3 dice and adding their values together.\nHit any key to roll the dice.....\n";
cin.ignore();
cout<<"\t die1\tdie2\tdie3\ttotal"<<endl;
cout<<"roll1:\t"<<dice1<<"\t"<<dice2<<"\t"<<dice3<<"\t"<<dice1+dice2+dice3<<endl;
cout<<"roll2:\t"<<ddice1<<"\t"<<ddice2<<"\t"<<ddice3<<"\t"<<ddice1+ddice2+ddice3<<endl;
cout<<"roll3:\t"<<dddice1<<"\t"<<dddice2<<"\t"<<dddice3<<"\t"<<dddice1+dddice2+dddice3<<endl<<endl;
cout<<"Your final score is\t"<<dice1+dice2+dice3+ddice1+ddice2+ddice3+dddice1+dddice2+dddice3<<endl;
cout<<"Play again? (1=yes)"<<endl;
int w;
cin>>w;
if(w!=1)break;
;}
return 0;
}
Yes I do. I want it to display the high score after it displays the score for every run. If it gets a higher number I then want that to be set as the new high score and so on.