高级守护
以下为BUG游戏:
#include<iostream>
#include<cmath>
#include<windows.h>
#include<ctime>
#include<cstdio>
using namespace std;
int main(){
int a,b=1,c=1000,d,e=0,f=10,g=0;
srand((int)time(NULL));
cout<<"游戏加载中";
Sleep(2000);
for(int i=0;i<=100;i+=4)
{
cout<<i<<"%";
system("cls");
}
cout<<"欢迎来到猜数游戏";
Sleep(2000);
system("cls");
cout<<3;
Sleep(1000);
system("cls");
cout<<2;
Sleep(1000);
system("cls");
cout<<1;
cout<<"开始吧\(≧w≦)/\n";
for(;;)
{
if(e<=0)
{
a=b+rand()%(c-b+1);
e++;
}
else
{
cout<<"您有"<<f<<"条命\n";
cout<<"请输入"<<c<<"和"<<b<<"之间的数\n";
cin>>d;
if(f>0)
{
if(d!=a)
{
f--;
if(a<d)
cout<<"大了\n";
else
cout<<"小了\n";
}
if(d==66&&g==0)
{
cout<<"恭喜您获得了彩蛋>_<!!!您将获得额外生命值>o<--------------五条!!!\n";
f+=5;
g++;
}
else if(d==a)
{
cout<<"对了>w<";
cout<<"续1,否2";
cout<<d;
if(d!=1)
return 0;
}
}
else
{
cout<<"GAME OVER!";
}
cout<<"继续1,否则2";
cin>>d;
if(d!=1)
cout<<"Bye~Bye~";
return 0;
}
}
return 0;
}
武瑞宸在2020-03-16 11:28:41追加了内容
别发笔记!!!!!!!!!!!!!!!!!!!!
初级天翼
这是老师上课的代码
看看我的
#include <iostream>
#include <ctime>
#include <windows.h>
#include <string>
using namespace std;
int main(){
int minn=1,maxn=100,ans,x,y=0;
string z;//名字
int hp,a;
srand((int)time(NULL));//随机数
x=minn+rand()%(maxn-minn+1);//范围
for(int i=1;i<=6;i++){//遍历空格
cout<<" ";
}
Sleep(500);
string d[100]={"欢","迎","来","到"," "," ","《","猜","字","游","戏","》"};
for(int i=1;i<=12;i++){//遍历12个字符
cout<<d[i-1];
Sleep(50);//每50毫秒输出一个
}
cout<<endl;
Sleep(1000);
system("color 1");//调色
cout<<"游戏启动中,正在载入游戏,请稍后";
for(int i=1;i<=9;i++){
Sleep(900);
cout<<".";//便利"."
}
cout<<"\n游戏加载完毕,现在您可以开始游戏了~"<<endl;
Sleep(1000);
system("cls");//清屏
Sleep(1000);
system("color 2");//调色
cout<<"请输入您的名字:"<<" ";
cin>>z;//字符"s"
Sleep(1000);
system("cls");//清屏
while(1){
hp=3;//初始
Sleep(1000);
system("cls");
cout<<"欢迎进入由0942华地1班全体同学制作的猜数游戏!~"<<endl;
Sleep(1000);
cout<<"祝您游戏愉快~~"<<endl;
Sleep(2000);
system("cls");
srand((int)time(NULL));
ans=minn+rand()%(maxn-minn+1);//ans为随机数
system("color 3");//调色
Sleep(1000);
cout<<"准备好了吗???游戏即将开始~~"<<endl;
Sleep(1000);
for(int i=1;i<=hp;i++){
system("color 4");
cout<<"您当前的HP为:"<<hp-i+1<<endl;//显示当前剩下次数
Sleep(1000);
cout<<"请输入一个"<<minn<<"~"<<maxn<<"之间的数字"<<endl;//输出范围
Sleep(1000);
cin>>a;//输入猜测数
Sleep(1000);
system("color 7");
//彩蛋,
if(a==x){
cout<<"恭喜,你发现了本游戏的彩蛋>o<"<<endl;
Sleep(1000);
cout<<"您将获得额外的生命值!"<<endl;
Sleep(1000);
cout<<"hp";
for(int i=1;i<=10;i++){//便利10次
system("color 5");//调色
Sleep(900);
cout<<"+";//每900毫秒就输出"+"
}
cout<<endl;//换行
hp+=5;//加生命
continue;//重新执行循环
}
if(a==ans&&i==1){//一次对
cout<<"666666 运气爆表,一次就猜对了(^o^),积分加1000!!!"<<endl;
Sleep(1000);
y+=1000; //增加积分
break;//跳出当前循环
}
else if(a==ans){//2或3次猜对了
cout<<"猜对了~>o<~,积分加500!!"<<endl;
Sleep(1000);
y+=500; //增加积分
break;//跳出当前循环
}
else if(a>ans&&i<hp){//不对
cout<<"您猜的数字大了点,尝试小一点的数字吧~"<<endl;//范围提示
Sleep(1000);
}
else if(a<ans&&i<hp){//不对
cout<<"您猜的数字小了点,尝试大一点的数字吧~"<<endl;//范围提示
Sleep(1000);
}
else{//不对
cout<<"很遗憾,你没有猜中,再来一次吧!加油~"<<endl;
Sleep(1000);
cout<<"本轮游戏的正确数字是:"<<ans;
Sleep(1000);
}
}
system("cls");
Sleep(1000);
system("color 6");
char c;//字符变量 "c"
cout<<"本轮游戏结束,您现在的积分是:"<<y<<endl<<"您是否向再来一次??"<<endl;//积分
Sleep(1000);
cout<<"输入Y继续游戏,输入其他字符退出游戏"<<endl;
Sleep(1000);
cin>>c;
if(c=='Y'){//继续
continue;
}
else{//不继续
cout<<"欢迎下次使用~Bye~Bye~^o^"<<endl;
system("pause");//暂停
break;//结束
}
}
return 0;
}
以上为自己编得
#include <iostream>
#include <ctime>
#include <windows.h>
#include <string>
using namespace std;
int main(){
int minn=1,maxn=100,ans,x,y=0;
string z;//名字
int hp,a;
for(int i=1;i<=6;i++){//遍历空格
cout<<" ";
}
Sleep(500);
string d[100]={"欢","迎","来","到"," "," ","《","猜","字","游","戏","》"};
for(int i=1;i<=12;i++){//遍历12个字符
cout<<d[i-1];
Sleep(50);//每50毫秒输出一个
}
cout<<endl;
Sleep(1000);
system("color 1");//调色
cout<<"游戏启动中,正在载入游戏,请稍后";
for(int i=1;i<=9;i++){
Sleep(900);
cout<<".";//便利"."
}
cout<<"\n游戏加载完毕,现在您可以开始游戏了~"<<endl;
Sleep(1000);
system("cls");//清屏
Sleep(1000);
system("color 2");//调色
cout<<"请输入您的名字:"<<" ";
cin>>z;//字符"s"
Sleep(1000);
system("cls");//清屏
cout<<"如果您想看规则,请按P"<<endl<<"不然则按O"<<endl;
char P;
cin>>P;
if(P==P){
Sleep(1000);
system("cls");
string j[100]={"规","则",":","猜","1","个","1","到","100","的","数",",","猜","对","就","赢","猜","错","就","输","。","有","3","次","机","会","。"};
for(int i=1;i<=25;i++){//遍历规则
Sleep(80);
cout<<j[i-1];
if(i%8==0){//换行
cout<<endl;
}
}
cout<<endl<<endl;
for(int i=1;i<=3;i++){
cout<<" ";
}
cout<<"如果看完则按“ok”"<<endl;//结束,开始游戏
string g;
cin>>g;
if(g=="ok"){
Sleep(100);
system("cls");
}
}
Sleep(2000);
system("cls");
while(1){
srand((int)time(NULL));//随机数
x=minn+rand()%(maxn-minn+1);//范围
hp=3;//初始
Sleep(1000);
system("cls");
cout<<"欢迎进入由0942华地1班全体同学制作的猜数游戏!~"<<endl;
Sleep(1000);
cout<<"祝您游戏愉快~~"<<endl;
Sleep(2000);
system("cls");
srand((int)time(NULL));
ans=minn+rand()%(maxn-minn+1);//ans为随机数
system("color 3");//调色
Sleep(1000);
cout<<"准备好了吗???游戏即将开始~~"<<endl;
Sleep(1000);
for(int i=1;i<=hp;i++){
system("color 4");
cout<<"您当前的HP为:"<<hp-i+1<<endl;//显示当前剩下次数
Sleep(1000);
cout<<"请输入一个"<<minn<<"~"<<maxn<<"之间的数字"<<endl;//输出范围
Sleep(1000);
cin>>a;//输入猜测数
Sleep(1000);
system("color 7");
//彩蛋,
if(a==x){
cout<<"恭喜,你发现了本游戏的彩蛋>o<"<<endl;
Sleep(1000);
cout<<"您将获得额外的生命值!"<<endl;
Sleep(1000);
cout<<"hp";
for(int i=1;i<=10;i++){//便利10次
system("color 5");//调色
Sleep(900);
cout<<"+";//每900毫秒就输出"+"
}
cout<<endl;//换行
hp+=5;//加生命
continue;//重新执行循环
}
if(a==ans&&i==1){//一次对
cout<<"666666 运气爆表,一次就猜对了(^o^),积分加1000!!!"<<endl;
Sleep(2000);
y+=1000;
system("cls");//增加积分
break;//跳出当前循环
}
else if(a==ans){//2或3次猜对了
cout<<"猜对了~>o<~,积分加500!!"<<endl;
Sleep(2000);
y+=500;
system("cls"); //增加积分
break;//跳出当前循环
}
else if(a>ans&&i<hp){//不对
cout<<"您猜的数字大了点,尝试小一点的数字吧~"<<endl;//范围提示
Sleep(2000);
system("cls");
}
else if(a<ans&&i<hp){//不对
cout<<"您猜的数字小了点,尝试大一点的数字吧~"<<endl;//范围提示
Sleep(2000);
system("cls");
}
else{//不对
cout<<"很遗憾,你没有猜中,再来一次吧!加油~"<<endl;
Sleep(2000);
cout<<"本轮游戏的正确数字是:"<<ans;
Sleep(1000);
system("cls");
}
}
system("cls");
Sleep(1000);
system("color 6");
char c;//字符变量 "c"
cout<<"本轮游戏结束,"<<z<<"现在的积分是:"<<y<<endl;
Sleep(2000);
if(y==500){
cout<<"恭喜您获得《运气小达人》的称号";
for(int i=1;i<=3;i++){
Sleep(800);
cout<<"!";
}
cout<<endl;
}
if(y==1000){
cout<<"恭喜您获得《运气之神》的称号";
for(int i=1;i<=6;i++){
Sleep(800);
cout<<"!";
}
cout<<endl;
}
Sleep(1000);
system("cls");
cout<<endl<<"您是否向再来一次??"<<endl;//积分
Sleep(1000);
cout<<"输入Y继续游戏,输入其他字符退出游戏"<<endl;
Sleep(1000);
cin>>c;
if(c=='Y'){//继续
continue;
}
else{//不继续
cout<<"欢迎下次使用~Bye~Bye~^o^"<<endl;
system("pause");//暂停
break;//结束
}
}
return 0;
}
我又改了一下!!!
中级天翼
@江齐悦 你能不能不要发老师上课写的代码啊!!!!!!!!!!!!!!
这样真的好吗?
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。@酷町侠
最近有很多人把老师上课时写的代码发到酷町问答上,这种情况应该怎么处置?
初级天翼
这是老师上课的代码
看看我的
#include <iostream>
#include <ctime>
#include <windows.h>
#include <string>
using namespace std;
int main(){
int minn=1,maxn=100,ans,x,y=0;
string z;//名字
int hp,a;
srand((int)time(NULL));//随机数
x=minn+rand()%(maxn-minn+1);//范围
for(int i=1;i<=6;i++){//遍历空格
cout<<" ";
}
Sleep(500);
string d[100]={"欢","迎","来","到"," "," ","《","猜","字","游","戏","》"};
for(int i=1;i<=12;i++){//遍历12个字符
cout<<d[i-1];
Sleep(50);//每50毫秒输出一个
}
cout<<endl;
Sleep(1000);
system("color 1");//调色
cout<<"游戏启动中,正在载入游戏,请稍后";
for(int i=1;i<=9;i++){
Sleep(900);
cout<<".";//便利"."
}
cout<<"\n游戏加载完毕,现在您可以开始游戏了~"<<endl;
Sleep(1000);
system("cls");//清屏
Sleep(1000);
system("color 2");//调色
cout<<"请输入您的名字:"<<" ";
cin>>z;//字符"s"
Sleep(1000);
system("cls");//清屏
while(1){
hp=3;//初始
Sleep(1000);
system("cls");
cout<<"欢迎进入由0942华地1班全体同学制作的猜数游戏!~"<<endl;
Sleep(1000);
cout<<"祝您游戏愉快~~"<<endl;
Sleep(2000);
system("cls");
srand((int)time(NULL));
ans=minn+rand()%(maxn-minn+1);//ans为随机数
system("color 3");//调色
Sleep(1000);
cout<<"准备好了吗???游戏即将开始~~"<<endl;
Sleep(1000);
for(int i=1;i<=hp;i++){
system("color 4");
cout<<"您当前的HP为:"<<hp-i+1<<endl;//显示当前剩下次数
Sleep(1000);
cout<<"请输入一个"<<minn<<"~"<<maxn<<"之间的数字"<<endl;//输出范围
Sleep(1000);
cin>>a;//输入猜测数
Sleep(1000);
system("color 7");
//彩蛋,
if(a==x){
cout<<"恭喜,你发现了本游戏的彩蛋>o<"<<endl;
Sleep(1000);
cout<<"您将获得额外的生命值!"<<endl;
Sleep(1000);
cout<<"hp";
for(int i=1;i<=10;i++){//便利10次
system("color 5");//调色
Sleep(900);
cout<<"+";//每900毫秒就输出"+"
}
cout<<endl;//换行
hp+=5;//加生命
continue;//重新执行循环
}
if(a==ans&&i==1){//一次对
cout<<"666666 运气爆表,一次就猜对了(^o^),积分加1000!!!"<<endl;
Sleep(1000);
y+=1000; //增加积分
break;//跳出当前循环
}
else if(a==ans){//2或3次猜对了
cout<<"猜对了~>o<~,积分加500!!"<<endl;
Sleep(1000);
y+=500; //增加积分
break;//跳出当前循环
}
else if(a>ans&&i<hp){//不对
cout<<"您猜的数字大了点,尝试小一点的数字吧~"<<endl;//范围提示
Sleep(1000);
}
else if(a<ans&&i<hp){//不对
cout<<"您猜的数字小了点,尝试大一点的数字吧~"<<endl;//范围提示
Sleep(1000);
}
else{//不对
cout<<"很遗憾,你没有猜中,再来一次吧!加油~"<<endl;
Sleep(1000);
cout<<"本轮游戏的正确数字是:"<<ans;
Sleep(1000);
}
}
system("cls");
Sleep(1000);
system("color 6");
char c;//字符变量 "c"
cout<<"本轮游戏结束,您现在的积分是:"<<y<<endl<<"您是否向再来一次??"<<endl;//积分
Sleep(1000);
cout<<"输入Y继续游戏,输入其他字符退出游戏"<<endl;
Sleep(1000);
cin>>c;
if(c=='Y'){//继续
continue;
}
else{//不继续
cout<<"欢迎下次使用~Bye~Bye~^o^"<<endl;
system("pause");//暂停
break;//结束
}
}
return 0;
}
以上为自己编得
#include <iostream>
#include <ctime>
#include <windows.h>
#include <string>
using namespace std;
int main(){
int minn=1,maxn=100,ans,x,y=0;
string z;//名字
int hp,a;
for(int i=1;i<=6;i++){//遍历空格
cout<<" ";
}
Sleep(500);
string d[100]={"欢","迎","来","到"," "," ","《","猜","字","游","戏","》"};
for(int i=1;i<=12;i++){//遍历12个字符
cout<<d[i-1];
Sleep(50);//每50毫秒输出一个
}
cout<<endl;
Sleep(1000);
system("color 1");//调色
cout<<"游戏启动中,正在载入游戏,请稍后";
for(int i=1;i<=9;i++){
Sleep(900);
cout<<".";//便利"."
}
cout<<"\n游戏加载完毕,现在您可以开始游戏了~"<<endl;
Sleep(1000);
system("cls");//清屏
Sleep(1000);
system("color 2");//调色
cout<<"请输入您的名字:"<<" ";
cin>>z;//字符"s"
Sleep(1000);
system("cls");//清屏
cout<<"如果您想看规则,请按P"<<endl<<"不然则按O"<<endl;
char P;
cin>>P;
if(P==P){
Sleep(1000);
system("cls");
string j[100]={"规","则",":","猜","1","个","1","到","100","的","数",",","猜","对","就","赢","猜","错","就","输","。","有","3","次","机","会","。"};
for(int i=1;i<=25;i++){//遍历规则
Sleep(80);
cout<<j[i-1];
if(i%8==0){//换行
cout<<endl;
}
}
cout<<endl<<endl;
for(int i=1;i<=3;i++){
cout<<" ";
}
cout<<"如果看完则按“ok”"<<endl;//结束,开始游戏
string g;
cin>>g;
if(g=="ok"){
Sleep(100);
system("cls");
}
}
Sleep(2000);
system("cls");
while(1){
srand((int)time(NULL));//随机数
x=minn+rand()%(maxn-minn+1);//范围
hp=3;//初始
Sleep(1000);
system("cls");
cout<<"欢迎进入由0942华地1班全体同学制作的猜数游戏!~"<<endl;
Sleep(1000);
cout<<"祝您游戏愉快~~"<<endl;
Sleep(2000);
system("cls");
srand((int)time(NULL));
ans=minn+rand()%(maxn-minn+1);//ans为随机数
system("color 3");//调色
Sleep(1000);
cout<<"准备好了吗???游戏即将开始~~"<<endl;
Sleep(1000);
for(int i=1;i<=hp;i++){
system("color 4");
cout<<"您当前的HP为:"<<hp-i+1<<endl;//显示当前剩下次数
Sleep(1000);
cout<<"请输入一个"<<minn<<"~"<<maxn<<"之间的数字"<<endl;//输出范围
Sleep(1000);
cin>>a;//输入猜测数
Sleep(1000);
system("color 7");
//彩蛋,
if(a==x){
cout<<"恭喜,你发现了本游戏的彩蛋>o<"<<endl;
Sleep(1000);
cout<<"您将获得额外的生命值!"<<endl;
Sleep(1000);
cout<<"hp";
for(int i=1;i<=10;i++){//便利10次
system("color 5");//调色
Sleep(900);
cout<<"+";//每900毫秒就输出"+"
}
cout<<endl;//换行
hp+=5;//加生命
continue;//重新执行循环
}
if(a==ans&&i==1){//一次对
cout<<"666666 运气爆表,一次就猜对了(^o^),积分加1000!!!"<<endl;
Sleep(2000);
y+=1000;
system("cls");//增加积分
break;//跳出当前循环
}
else if(a==ans){//2或3次猜对了
cout<<"猜对了~>o<~,积分加500!!"<<endl;
Sleep(2000);
y+=500;
system("cls"); //增加积分
break;//跳出当前循环
}
else if(a>ans&&i<hp){//不对
cout<<"您猜的数字大了点,尝试小一点的数字吧~"<<endl;//范围提示
Sleep(2000);
system("cls");
}
else if(a<ans&&i<hp){//不对
cout<<"您猜的数字小了点,尝试大一点的数字吧~"<<endl;//范围提示
Sleep(2000);
system("cls");
}
else{//不对
cout<<"很遗憾,你没有猜中,再来一次吧!加油~"<<endl;
Sleep(2000);
cout<<"本轮游戏的正确数字是:"<<ans;
Sleep(1000);
system("cls");
}
}
system("cls");
Sleep(1000);
system("color 6");
char c;//字符变量 "c"
cout<<"本轮游戏结束,"<<z<<"现在的积分是:"<<y<<endl;
Sleep(2000);
if(y==500){
cout<<"恭喜您获得《运气小达人》的称号";
for(int i=1;i<=3;i++){
Sleep(800);
cout<<"!";
}
cout<<endl;
}
if(y==1000){
cout<<"恭喜您获得《运气之神》的称号";
for(int i=1;i<=6;i++){
Sleep(800);
cout<<"!";
}
cout<<endl;
}
Sleep(1000);
system("cls");
cout<<endl<<"您是否向再来一次??"<<endl;//积分
Sleep(1000);
cout<<"输入Y继续游戏,输入其他字符退出游戏"<<endl;
Sleep(1000);
cin>>c;
if(c=='Y'){//继续
continue;
}
else{//不继续
cout<<"欢迎下次使用~Bye~Bye~^o^"<<endl;
system("pause");//暂停
break;//结束
}
}
return 0;
}
我又改了一下!!!