How To Determine The Best Score?
I am doing a lab regarding 'guess number game'
Actually,the answer should be the random number,but I set the exact number to 88,because it is easy for me to test other requirement.
I need to printf("Best Score so far [X]")
How to make comparison between the previous and now guess game,and define the best score.
#include <stdio.h>
int main()
{
int GusNum,TotalNum,BesSor,a;
char again;
do
{ TotalNum=0;
do
{
printf("Guess what the lucky number is <between 1 and 100>,then <Enter>:");
scanf("%d",&GusNum);
if(GusNum>=89&&GusNum<=100)
printf("The number you typed is [%d] -Too LARGE,guess the lucky number again!\n\n",GusNum);
else if (GusNum<=87&&GusNum>=1)
printf("The number you typed is [%d] -Too SMALL,guess the lucky number again!\n\n",GusNum);
else if(GusNum==88)
printf("OK This is your LUCKY NUMBER [88] Well Done!\n");
else
printf("OUT OF THE RANGE \n");
TotalNum++;
}while(GusNum!=88);
if(GusNum==88)
{
printf("Number of attempt [%d]\n\n",TotalNum);
/*
if(a>TotalNum)
{
printf("Best score so far [%d]\n",TotalNum);
}else printf("Best score so far [%d]\n",a);
the wrong part i want to set the best socre*/
printf("Play again Type 'y' for YES; all other characters for NO:");
scanf(" %c", &again);
}
}while(again=='y');
}