+ 1
THERE IS NO <ARRAY> LIBRARY IN 2008 CPP. PLEASE HELP!
PLEASE HELP ME ON THIS 😢
31 Answers
+ 2
Well, Ill make it c++98 compatible...
Will that work?
+ 1
can you make it happen so i can put it on visual studio 2008? 😢
+ 1
@kinshuk
my prof did not accept it cause it didnt run on visual 2008 😢😢
+ 1
Sure!
But Please add stdafx.h later if you have selected precompilation...
+ 1
i'm so dead if your bot there to help 💔
+ 1
#include <iostream>
//#include "stdafx.h"
//This is a specific project requirement
#include <ctime>
#include <cstdlib>
#include <string>
//Forgot this, maybe this is why array didn't work?
using namespace std;
int main()
{
cout <<"======THE TURTLE RACE======"<<endl;
const int numberOfTurtles = 4;
string turtle[4]; //Just changed this...
srand(time(NULL));
cout << "PLACE YOUR BET HERE!";
cout << "\n\nEnter your name on your turtle!\n\n";
for(int i = 0; i < 4; i++){
cin >> turtle[i];
}
int winner;
// here will chose the winner
winner = rand() % numberOfTurtles;
int secondPlace;
int thirdPlace;
int fourthPlace;
bool foundSecond = false;
bool foundThird = false;
bool foundFourth = false;
// here we get the second place
while(!foundSecond) {
secondPlace = rand() % numberOfTurtles;
if(secondPlace != winner)
foundSecond = true;
}
// here we get the third place
while(!foundThird ) {
thirdPlace = rand() % numberOfTurtles;
if(thirdPlace != secondPlace && thirdPlace != winner)
foundThird = true;
}
// here we get the fourth place
while(!foundFourth ) {
fourthPlace = rand() % numberOfTurtles;
if( fourthPlace != secondPlace && fourthPlace != winner && fourthPlace != thirdPlace )
foundFourth = true;
}
cout << "Winner: " << turtle[winner] << endl;
cout << "Second place: " << turtle[secondPlace] <<endl;
cout << "Third place: " << turtle[thirdPlace] <<endl;
cout << "Fourth place: " << turtle[fourthPlace] <<endl;
cout << "\nCONGRATULLATIONS! "<< turtle[winner]<<endl;
cout << "Your turtle has won and your money has beed doubled!\n";
cout << "TRY AGAIN AND BE RICH!" <<endl;
return 0;
}
+ 1
Please try this and tell me...
+ 1
I have Visual Studio 2015, so it may still be a problem...
+ 1
Now what happened?
+ 1
Did you try running it?
+ 1
Ok...
+ 1
stdafx.h, not sdhfx.h
+ 1
or try without that...
+ 1
Or if you don't want the program to end...
int age;
cout<<"Enter your age, Sir...";cin>>age;
while(age<18)
{
cout<<"You're not eligible..., Try again..."<<endl;
cout<<"Enter your age, Sir...";cin>>age;
}
+ 1
I suggest you create a new project, win32 console app, and mark the precompiled header checkbox on the page which has the finish button.
then add your code in the new cpp file created, without removing stdafx.h or windows.h from it...
+ 1
@kinshuk
I'll try to finish this tomorow 😊
0
#include <iostream>
#include <array>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
cout <<"======THE TURTLE RACE======"<<endl;
const int numberOfTurtles = 4;
array<string,4> turtle;
srand(time(NULL));
cout << "PLACE YOUR BET HERE!";
cout << "\n\nEnter your name on your turtle!\n\n";
for(int i = 0; i < 4; i++){
cin >> turtle[i];
}
int winner;
// here will chose the winner
winner = rand() % numberOfTurtles;
int secondPlace;
int thirdPlace;
int fourthPlace;
bool foundSecond = false;
bool foundThird = false;
bool foundFourth = false;
// here we get the second place
while(!foundSecond) {
secondPlace = rand() % numberOfTurtles;
if(secondPlace != winner)
foundSecond = true;
}
// here we get the third place
while(!foundThird ) {
thirdPlace = rand() % numberOfTurtles;
if(thirdPlace != secondPlace && thirdPlace != winner)
foundThird = true;
}
// here we get the fourth place
while(!foundFourth ) {
fourthPlace = rand() % numberOfTurtles;
if( fourthPlace != secondPlace && fourthPlace != winner && fourthPlace != thirdPlace )
foundFourth = true;
}
cout << "Winner: " << turtle[winner] << endl;
cout << "Second place: " << turtle[secondPlace] <<endl;
cout << "Third place: " << turtle[thirdPlace] <<endl;
cout << "Fourth place: " << turtle[fourthPlace] <<endl;
cout << "\nCONGRATULLATIONS! "<< turtle[winner]<<endl;
cout << "Your turtle has won and your money has beed doubled!\n";
cout << "TRY AGAIN AND BE RICH!" <<endl;
return 0;
}
0
this is my code, can someone convert this to a code with no array but same output? rhabks
0
how sir? can you teach me later how? thabk you very much sir 😣
0
@kinshuk
thank you sir 😣😣 please help me this day, I rwally need someone right now. I'm so brokw