编写一个猜数字游戏,有一定的容错功能,界面友好,功能齐全。

来源:百度知道 编辑:UC知道 时间:2024/05/30 01:52:59
A、一个四位数,各位上的数字不重复,从1到9。
B、按以下提示猜出这个四位数。
C、每次猜测输入的数据给出类似的提示*A*B。
D、其中A前的*代表你本次猜对了多少个数字。
E、其中B前的*代表你本次猜对的数字并且位置正确的个数。

#include<iostream>
#include<time.h>
#include<stdlib.h>
using namespace std;
class game
{
public:
void function1()
{
int t,k;
cout<<endl<<"*********开始游戏按1:**********"<<endl;
cout<<"*********查看游规则按2:**********"<<endl;
cout<<"*********退出请按3:**********"<<endl;
while(t)
{
cin>>k;
switch(k)
{
case 1: {random();t=0;};break;
case 2: {tip();t=0;};break;
case 3: {exit(1);t=0;};break;
default:cout<<"按键无效!";t=0;break;
}
}
}
void function2()
{
int t,k;
cout<<endl<<"重玩游戏按1"<<endl;
cout<<"退出游戏按2"<<endl;

while(t)
{
cin>>k;
switch(k)
{
case 1: {random();t=0