#include<iostream.h>
#include <math.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <ctype.h>
usingnamespace std;
void compraing();
int Myarray [10]; ///i need help
for(int i=0;i<10;i++) ///
int Myarray[i]=0; ///
// int main
int main() {
int random, guess, dist, numgames, play, turn=0;
do {
turn=0;
system("cls");
numgames=1;
compraing();
cout<<"Do you want to play again(1 for yes, 2 for no): ";
cin>>play;
numgames=1;
if (play==2)
numgames=0;
} while (numgames==1);
return 0;
}
///this is the function
void compraing()
{int guess,dist,turn,random,numgames;
turn=0;
system("cls");
srand((unsigned)time(0));
random= (rand()%200) +1;
do {
turn++;
cout<<"What is your guess, between 1 and 200? ";
cin>>guess;
dist=random-guess;
dist=abs(dist);
cout<<random;
if (dist==0) {
cout<<"YOU GUESSED IT";
cout<<endl;
break; }
elseif (dist<=3 && dist>0) {
cout<<"You are HOT";
cout<<endl; }
elseif (dist<=5 && dist>3) {
cout<<"You are WARM";
cout<<endl; }
elseif (dist<=8 && dist>5) {
cout<<"You are COOL";
cout<<endl; }
elseif (dist>8) {
cout<<"You are FREEZING";
cout<<endl; }
if (turn>=10){
cout<<"You have lost because you went over your turn limit of 10 turns to guess /n/n ";
break; }
} while (true);
cout<<"It took you "<<turn<<" guesses to guess the correct number!";
cout<<endl ;
Myarray[turn-1]=turn; //my teacher told me to do this
}
The assignment was to make a random generator and you have 10 guesses to get the number.. (i got that part)........ the next part is since you can play again because of the loop i need to make a array of the numbers it took you to try to guess the numbers from lowest to highest.
for example: lets say it took me 10 turns to guess the first time i played
then after because of the loop i played again and it took me 5 turns.... i need to print those numbers in a array format like for example ; 5,10 ......