5个回答
2014-01-23
展开全部
#include <stdio.h>
#include <math.h>
#include <time.h>
void main()
{
int magic,guess,k;
char over,c;
printf("退出游戏请输入z\n");
do
{
srand (time(NULL));
magic=rand()%100+1;
printf("请输入猜测的数字1~100\n");
for(k=0;guess!=magic;k++)
{
scanf("%d",&guess);
if (guess==magic)printf("恭喜,你猜对了!\n");
scanf("%c",&over);
if (over=='z')
{
printf("感谢你的参与!!\n");
exit(0);
}
if(guess<magic)printf("太小了!\n");
if(guess>magic)printf("太大了!\n");
}
printf("你猜团手戚了%d次\n",k);
printf("是薯烂否继续游戏y/n\n"塌陵);
scanf("%c",&c);
}while(c=='y');
if(c=='n'||c=='z')
{
printf("感谢你的参与!!\n");
exit(0);
}
getch();
}
#include <math.h>
#include <time.h>
void main()
{
int magic,guess,k;
char over,c;
printf("退出游戏请输入z\n");
do
{
srand (time(NULL));
magic=rand()%100+1;
printf("请输入猜测的数字1~100\n");
for(k=0;guess!=magic;k++)
{
scanf("%d",&guess);
if (guess==magic)printf("恭喜,你猜对了!\n");
scanf("%c",&over);
if (over=='z')
{
printf("感谢你的参与!!\n");
exit(0);
}
if(guess<magic)printf("太小了!\n");
if(guess>magic)printf("太大了!\n");
}
printf("你猜团手戚了%d次\n",k);
printf("是薯烂否继续游戏y/n\n"塌陵);
scanf("%c",&c);
}while(c=='y');
if(c=='n'||c=='z')
{
printf("感谢你的参与!!\n");
exit(0);
}
getch();
}
推荐于2018-03-14
展开全部
#include<stdio.h>
#include<math.h>
#include<time.h>巧腊弊
void main()
{
int i,j;
srand((unsigned)time(NULL));
i=rand()%100;
print("猜电脑出的孝族一个100内的数:/n");
while(true)
{
scanf("%d/n",&j);
if(j==i) {print("猜中了,游戏结束/n");break;}
print("没猜局段中。请继续猜。/n");
}
}
#include<math.h>
#include<time.h>巧腊弊
void main()
{
int i,j;
srand((unsigned)time(NULL));
i=rand()%100;
print("猜电脑出的孝族一个100内的数:/n");
while(true)
{
scanf("%d/n",&j);
if(j==i) {print("猜中了,游戏结束/n");break;}
print("没猜局段中。请继续猜。/n");
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2014-01-23
展开全部
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
int i, j, life, maxrand;
char c;
void Start ();
void GetResults ();
void Start (){
i = 0;
j = 0;
life = 0;
maxrand = 6;
cout << "备如Select difficulty mode:\n";
cout << "1 : Easy (0-15)\n";
cout << "2 : Medium (0-30)\n";
cout << "3 : Difficult (0-50)\n";
cout << "or type another key to quit\n";
c = 30;
cin >> c;
cout << "\n";
switch (c){
case '1' : maxrand = 15;
break;
case '2' : maxrand = 30;
break;
case '3' : maxrand = 50;
break;
default : exit(0);
break;
}
life = 5;
srand( (unsigned)time( NULL ) );
j = rand() % maxrand;
GetResults();
}
void GetResults (){
if (life <= 0){
cout << "You lose !\n\n";
Start();
}
cout << "Type a number: \n";
cin >> i;
if ((i>maxrand) || (i<0)){
cout << "Error : Number not between 0 and \n" << maxrand;
GetResults();
}
if (i == j){
cout << "YOU WIN !\n\n";
Start();
}
else if (i>j){
cout << "Too BIG\n";
life = life - 1;
cout << "Number of remaining life: " << life << "\n\n";
GetResults();
}
else if (i<j){
cout << "Too SMALL\n"烂纳;
life = life - 1;
cout << "Number of remaining life:\饥滚没n" << life << "\n\n";
GetResults();
}
}
int main ()
{
cout << "** Jackpot game **\n";
cout << "The goal of this game is to guess a number. You will be ask to type\n";
cout << "a number (you have 5 guess)\n";
cout << "Jackpot will then tell you if this number is too big of too small compared to the secret number to find\n\n";
Start();
return 0;
}
#include <stdlib.h>
#include <time.h>
using namespace std;
int i, j, life, maxrand;
char c;
void Start ();
void GetResults ();
void Start (){
i = 0;
j = 0;
life = 0;
maxrand = 6;
cout << "备如Select difficulty mode:\n";
cout << "1 : Easy (0-15)\n";
cout << "2 : Medium (0-30)\n";
cout << "3 : Difficult (0-50)\n";
cout << "or type another key to quit\n";
c = 30;
cin >> c;
cout << "\n";
switch (c){
case '1' : maxrand = 15;
break;
case '2' : maxrand = 30;
break;
case '3' : maxrand = 50;
break;
default : exit(0);
break;
}
life = 5;
srand( (unsigned)time( NULL ) );
j = rand() % maxrand;
GetResults();
}
void GetResults (){
if (life <= 0){
cout << "You lose !\n\n";
Start();
}
cout << "Type a number: \n";
cin >> i;
if ((i>maxrand) || (i<0)){
cout << "Error : Number not between 0 and \n" << maxrand;
GetResults();
}
if (i == j){
cout << "YOU WIN !\n\n";
Start();
}
else if (i>j){
cout << "Too BIG\n";
life = life - 1;
cout << "Number of remaining life: " << life << "\n\n";
GetResults();
}
else if (i<j){
cout << "Too SMALL\n"烂纳;
life = life - 1;
cout << "Number of remaining life:\饥滚没n" << life << "\n\n";
GetResults();
}
}
int main ()
{
cout << "** Jackpot game **\n";
cout << "The goal of this game is to guess a number. You will be ask to type\n";
cout << "a number (you have 5 guess)\n";
cout << "Jackpot will then tell you if this number is too big of too small compared to the secret number to find\n\n";
Start();
return 0;
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
有个几年前编好的猜数字,但是代码找不到了,没有没有记忆成绩的功能,楼主要不?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2014-01-23
展开全部
如果要求界面就要用控件
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询