0
已解决
董宇昊
初级启示者
初级启示者
由于之前的被大家嫌弃
所以我有有了新的游戏!!
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main(){
string k;
k="欢迎来到猜数游戏!";
cout<<k<<"\n";
int a;
srand(time(NULL));
a=rand()%100+1;
int b,i;
k="你要猜几次?";
cout<<k<<"\n";
cin>>i;
while(i){
cin>>b;
if(b>a) k="猜大了!";
else if(a>b) k="猜小了!";
else if(a==b) k="猜中了!";
i--;
cout<<k<<"\n";
if(k=="猜中了") return 0;
k="正确答案是:";
if(i==0) cout<<a;
}
return 0;
}
绝对正版,请勿抄袭
0
已采纳
王子逸
新手天翼
新手天翼
我给你代码,你自己试试
#include<iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
int main()
{
int some=10,g=0;
int z;
char aaa;
string name,p;
char a;
cout<<"\nUsename:";
cin>>name;
cout<<"Password:";
cin>>p;
if(name=="player"&&p=="QQ4399")
{
int t=0;
int n;
cout<<"\n\n\tWelcome to guess my Numder.\n\n";
for(int i=1;i=1;i)
{
cout<<"\n\na.Easy(0~50)\nb.ordinary(0~100)\nc.difficult(0~200)\n";
cin>>a;
if(a=='a')z=50;
else if(a=='b')z=100;
else if(a=='c')z=200;
srand(static_cast<unsigned int>(time(0)));
int shu=rand()%z+1;
do
{ cout<<"Enter a guess:";
cin>>n;
t++;
if(n>shu)
{
cout<<"Too big!\n\n";
some--;
}
else if(n<shu)
{
cout<<"Too small!\n\n";
some--;
}
else
{
cout<<"You are good! You got it in "<<t<<" guesses.\n";
}
}while (n != shu);
g+=some-1;
cout<<g<<" fraction\tYou are guess numder king!";
t=0;some=10;
cout<<"\nDo you think still play?(y/n):";
cin>>aaa;
if(aaa=='y')
i++;
if(aaa=='n')
{
cout<<"\n\t\tGood bye!";
break;
}
}
}
else
{
cout<<"We don't have this Usename or Password.\n";
}
return 0;
}
账号是player 密码是QQ4399
王子逸在2020-05-27 17:52:19追加了内容
这是我以前编的,希望对你有帮助
0
0
董宇昊
初级启示者
初级启示者
代码有一处错误!
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main(){
string k;
int a;
srand(time(NULL));
a=rand()%100+1;
int b,i;
k="你要猜几次?";
cout<<k<<"\n";
cin>>i;
while(i){
cin>>b;
if(b>a) k="猜大了!";
else if(a>b) k="猜小了!";
else if(a==b) k="猜中了!";
i--;
cout<<k<<"\n";
if(k=="猜中了") return 0;
k="正确答案是:";
if(i==0){
cout<<k<<a;
}
}
return 0;
}
这才是正确代码
0
0
0