-
cout
Code:
#include <conio.h>
#include <iostream>
#include <stdlib.h>
#include <ctime>
int User_Score, Comp_Score;
int User_Option, Comp_Option;
char name[15];
int Q = 0;
int RandInt(int a,int b)
{
return a + rand() % (b - a + 1);
}
int main()
{
cout << "Paper/Scissor/Rock 0.1\n\n";
cout << "Please enter name: ";
cin >> name;
cout << "\n";
do
{
srand(time(NULL));
int x = RandInt(1,3);
system("pause");
system("cls");
cout << "Scoreboard:\t\t Q-uit\n\n"<<name<<": "<<User_Score;
cout << "\nComputer: "<<Comp_Score<<"\n\n";
cout << "Please select one of the following:\n\n";
cout << "1)Paper\n2)Scissors\n3)Rock\n\n";
cin >> User_Option;
cout << "\n";
Comp_Option = x; //Assigning Comp_Options value as x, the value of x
//changes between 1 and 3 every loop
//Here are all the possible out comes, relevant messages and variable updates
if(User_Option == 1 && Comp_Option == 1)
{
cout << "This round is a draw.\n";
}
else if(User_Option == 1 && Comp_Option == 2)
{
cout << "You lose try again.\n";
Comp_Score++;
}
else if(User_Option == 1 && Comp_Option == 3)
{
cout << "Congratulations you win.\n";
User_Score++;
}
else if(User_Option == 2 && Comp_Option == 1)
{
cout << "Congratulations you win.\n";
User_Score++;
}
else if(User_Option == 2 && Comp_Option == 2)
{
cout << "This round is a draw.\n";
}
else if(User_Option == 2 && Comp_Option == 3)
{
cout << "You lose try again.\n";
Comp_Score++;
}
else if(User_Option == 3 && Comp_Option == 1)
{
cout << "You lose try again.\n";
Comp_Score++;
}
else if(User_Option == 3 && Comp_Option == 2)
{
cout << "Congratulations you win.\n";
User_Score++;
}
else if(User_Option == 3 && Comp_Option == 3)
{
cout << "This round is a draw.\n";
}
else if(User_Option == Q)
{
Q = 1;
}
else
{
cout << "Invaild input.\n";
}
} //End Do
while(Q != 1); //The loop breaks
system("cls"); //Take the ingame data off
cout << "Goodbye\n\n";
system("pause"); //Pause so Goodbye msg is viewable
return 0;
} //End Int main()
First, this isnt mine, all the credit goes to kirdra...I had a question on this though. The only error messages you get after running this have to do with all the cout statements (undefined identifier 'cout'). Im just beginning C++ and i went through this couldn't find anything wrong from what Ive been taught so far. Do you need to include another library or restructure it..ect. in order for the couts to work?
-
I already posted the answer to this in the original post.
-
...which was a 2 year bump...
-
I didn't even notice that...:eek: :eek:
wow....yah, it is two years old....I guess my post is kinda irrelevant. Gah, stupid thread bumpers.
-
To answer your question, you need to put "using namespace std;" right after your includes.
-
you can be more specific if cout is the only problem.
using std::cout; /put after the #include statements