用C++实现猜英文单词游戏

核心提示因为在机上写,我也是个菜鸟,写得不是很好你参考一样吧#include<iostream.h>#include<stdlib.h>#include<string.h>#include<time.h>#include<conio.h>#incl

因为在机上写,我也是个菜鸟,写得不是很好

你参考一样吧

#include<iostream.h>

#include

<stdlib.h>

#include

<string.h>

#include

<time.h>

#include<conio.h>

#include<process.h>

int

beg=200;

char

str[26];

void

main()

{

int

n,money=0,y=0,m=0,right=0;

char

array[26];

void

clrscr();

cout<<"请输入您准备猜的单词个数N=

";

cin>>n;

srand((unsigned

int)time(NULL));

for(int

i=0;i<n;i++)

str[i]=(char)((rand()%26)+65);

cout<<"******game

start*******";

cout<<"您有200元的赌柱,好好珍惜"<<endl;

cout<<"这次你打算压多少?"<<endl;

cin>>money;

if(money<0

||

money>200)

cout<<"好好压,别乱想"<<endl;

else

cout<<"给你个小提示,第一个单词是"<<str[0]<<endl;

cout<<"单词数是:

"<<n;

cout<<"请你输入猜的单词:

"<<endl;

for(int

k=1;k<n;k++)

{

{

n--;

cout<<"您还有"<<n<<"机会"<<endl;

cin>>array[k];

}

for(i=0;i<n;i++)

if(array[i]

==str[i])

{

right++;

cout<<"您猜对了"<<right<<"个"<<endl;

beg-=money;

}

}

cout<<"您只猜对了"<<right<<",还剩"<<(m=n-right)<<"没有猜对,一个扣5分"<<endl;

beg-=(m*5+money);

if(beg<0)

{cout<<"你的金额不足了"<<endl;

cout<<"正确答案是:

"<<endl;

for(int

j=0;j<=n;j++)

cout<<(char)str[j]<<"

";

void

exit();}

else

{

cout<<"还剩"<<beg<<endl;

cout<<"正确答案是:

"<<endl;

for(int

j=0;j<=n;j++)

cout<<(char)str[j]<<"

";

}

}

 
友情链接
鄂ICP备19019357号-22