c++小游戏

#include<iostream> //Standard input/output
#include<string> //String manipulation
#include<cctype> //Character manipulation and testing
#include<fstream> //File stream
#include<cstdlib> //Used for random function
#include<time.h> //Used for better random number
#include"draw.h" //run the draw.h file

using namespace std;
//Function declerations
void instruction(int& choice); //Give instructions and gets choice
void usergame(int i); /瞎孙散/Plays 2nd user game
void compgame(int i); //Plays against computer
//Tests current letter and raplaces starred word
void test(string word,char letter,int& numwrong,string& temp,int i);
//Checks current letter and adds it to letters chosen output if not entered already
void lchosen(char letter,string& letterchosen,int& check,int& chosencounter,int i);
void rnd(string& word,int i); //Gets random word from file
void drawman(int numguess,int numwrong,int i); //Draws hangman
inline istream& Flush(istream& stream); //Flushses cin stream

//Start of main

int main()
{
int i=0; /磨氏/Counter variable for loops
int exit=0; //Main loop exit variable
int choice; //users input choice for type of game or to exit
//Main control loop
do{ //while exit!=1
system("cls"); //执行系统命令清屏
instruction(choice);//Give instructions
switch(choice)
{
case 1:
usergame(i);//Calls user game
break;
case 2:
compgame(i);//Calls computer game
break;
case 3:
cout<<"Goodbye"<<endl;
exit=1;
break;
default:
cerr<<"Invalid choice---try again"<<endl;
}
}while(exit!=1);
//End main loop
system("pause"); //执行系统命令:暂停
return 0;
}
//End main

void instruction(int& choice)
{
cout<<"凯厅 --Hangman--"<<endl<<endl;
cout<<" Created by laser"<<endl<<endl;
cout<<"*************************************************"<<endl;
cout<<endl;
cout<<"Enter --1--to play against user"<<endl;
cout<<"Enter --2--to play against computer"<<endl;
cout<<"Enter --3--to quit"<<endl;
cout<<endl;
cout<<"*************************************************"<<endl<<endl;
cout<<"Choice: ";
cin&

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值