| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1232 人关注过本帖
标题:一篇由满屏 printf 和 if 组成的猜猜猜文字游戏
只看楼主 加入收藏
暧昧未暖
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2021-7-16
收藏
 问题点数:0 回复次数:1 
一篇由满屏 printf 和 if 组成的猜猜猜文字游戏
刚学C语言,一时无聊突然想到!
哎,干嘛不自己弄程序呢?

不会循环?没事我们有goto!
不会跳转?没事我们有goto!
哦豁,不会敲代码?对了有百度呢!

然后一个由满篇 printf 和 if 组成的猜猜猜就大功告成了,哈哈哈

(好像论坛限制了空格输入,游戏里面的文字对不齐,可惜了我满屏空白键和\n的完美布局啊
源码如下:

#include <stdio.h>
#include <stdlib.h>/*添加颜色*/
#include <windows.h>/*添加时间*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
     int    a,b,c=2,e,f=3,g,d=300,h=1000,i,j,k;
     do{
         b=3;
         system("cls");
         system("color 0e");/*添加颜色*/
         puts("\n\n                   猜猜猜");
         puts("\n\n\n\n\n游戏规则:\n1.游戏总共18点,9点或9点以下为小,10点或10点以上为大,骰子相等为豹子!");
        puts("2.赔率计算:猜中大小均为1:1,豹子为3倍!");
         puts("\n\n\n\n\n友情提示:\n博一博,单车变摩托,赌一赌,摩托变吉普。");
         printf("\n\n\n\n                      输入任意数字进入游戏\n");    scanf("%d",&a);
        if(a<0){
             while(b>=0)
            {
                system("cls");
                system("color 80");
                printf("\n\n\n\n\n\n\n\n\n\n\n             官人请输入准确的指令,%d秒后重试",b);
                Sleep(1000);
                b=b-1;
             }}
         }while(a<0);
         while(c<=10)
         {
             system("cls");
            system("color 06");
            printf("\n\n\n\n\n\n\n\n\n\n\n\n               正在加载游戏, 已加载 %d0",c);
            Sleep(1000);
            c=c+2;
         }
         do{
         a:
        system("cls");
        system("color 3f");
        printf("\n\n\n                             庄家");
        printf("\n\n                         要想富,下重注!");
           printf("\n\n\n\n                 即将开奖,请尽快下注");
        printf("\n\n\n剩余积分: %d \n下注金额:\n0:梭哈\n",d);    scanf("%d",&e);
        if(e>d||d==0){
            system("cls");
            system("color 80");
            printf("\n\n\n\n\n\n\n\n\n\n\n                    客官积分不够了呢!");
            printf("\n\n\n\n\n\n\n\n\n\n1.充值\n2.返回\n3.退出游戏\n");    scanf("%d",&a);
            while(a==1||a==2||a==3){
                if(a==1){
                    goto    b;}
                if(a==2){
                    goto    a;}
                if(a==3){
                    goto    c;}}}
        if(e==0){
             e=d;}
        printf("\n\n买定离手:\n1.小\n2.大\n3.豹子\n");    scanf("%d",&g);
            if(g<1||g>3){
                    system("cls");
                    system("color 80");
                    printf("\n\n\n\n\n\n\n\n\n\n\n\n               请客官按规定买定离手!");
                    Sleep(3000);
                    goto    a;}
        system("cls");
        system("color 70");
        puts("\n\n\n\n\n\n\n\n\n\n\n\n                    正在开奖中...");
        srand((unsigned)time(NULL));
    i = rand()%6+1;
        Sleep(1000);
        srand((unsigned)time(NULL));
    j = rand()%6+1;
        Sleep(1000);
        srand((unsigned)time(NULL));
    k = rand()%6+1;
        Sleep(1000);
        system("cls");
        system("color b0");
        printf("本次开奖号码为:\n\n%d     %d     %d",i,j,k);
        if(i==j&&i==k){
            printf("\n\n开奖结果为:3.豹子");}
        if(i!=j||i!=k){
            if(i+j+k<=10){
                printf("\n\n开奖结果为:1.小");}
            if(i+j+k>=11){
                printf("\n\n开奖结果为:2.大");}}
            if(i==j&&i==k)
            {
                if(g==1){
                system("color 0c");
                printf("\n\n\n\n\n\n\n\n                      很遗憾您未中奖");
                printf("\n\n您猜中的结果是:1.小");
                printf("\n\n当前积分为:%d",d-=e);}
                if(g==2){
                system("color 0c");
                printf("\n\n\n\n\n\n\n\n                      很遗憾您未中奖");
                printf("\n\n您猜中的结果是:2.大");
                printf("\n\n当前积分为:%d",d-=e);}
                if(g==3){
                system("color 3a");
                printf("\n\n\n\n\n\n\n\n                   恭喜您猜中本场豹子!");
                printf("\n\n您猜中的结果是:3.豹子");
                printf("\n\n当前积分为:%d",d+=e*3);}
                }
            if(i!=j||i!=k){
            if(i+j+k<=10)
                {
                if(g==1){
                printf("\n\n\n\n\n\n\n\n                       恭喜您猜对了!");
                printf("\n\n您猜中的结果是:1.小");
                printf("\n\n当前积分为:%d",d+=e);}
                if(g==2){
                system("color 0c");
                printf("\n\n\n\n\n\n\n\n                      很遗憾您未中奖");
                printf("\n\n您猜中的结果是:2.大");
                printf("\n\n当前积分为:%d",d-=e);}
                if(g==3){
                system("color 0c");
                printf("\n\n\n\n\n\n\n\n                      很遗憾您未中奖");
                printf("\n\n您猜中的结果是:3.豹子");
                printf("\n\n当前积分为:%d",d-=e);}
                }
            if(i+j+k>=11)
                {
                if(g==1){
                system("color 0c");
                printf("\n\n\n\n\n\n\n\n                      很遗憾您未中奖");
                printf("\n\n您猜中的结果是:1.小");
                printf("\n\n当前积分为:%d",d-=e);}
                if(g==2){
                printf("\n\n\n\n\n\n\n\n                       恭喜您猜对了!");
                printf("\n\n您猜中的结果是:2.大");
                printf("\n\n当前积分为:%d",d+=e);}
                if(g==3){
                system("color 0c");
                printf("\n\n\n\n\n\n\n\n                      很遗憾您未中奖");
                printf("\n\n您猜中的结果是:3.豹子");
                printf("\n\n当前积分为:%d",d-=e);}
                } }
            if(d==0){
            system("color 0c");
                puts("\n\n\n\n积分没有了\n不能再继续愉快的游戏是否充值?");
                printf("1.是\n2.否\n");        scanf("%d",&a);
                    if(a==1){
                    b:
                        system("color 0c");
                        system("cls");
                        printf("\n\n\n请输入卡密进行充值\n输入1.返回游戏\n输入2.退出游戏\n");    scanf("%d",&a);
                            if(a==1){
                                goto    a;}
                            if(a==2){
                                goto    c;}
                            if(a==123123){
                                d+=100;
                                system("cls");
                                printf("\n\n充值成功!获得100积分!");
                                printf("\n当前积分为:%d",d);}
                            else{
                                system("cls");
                                printf("\n\n\n充值失败请检查后重新输入");
                                Sleep(1500);
                                goto    b;}}}
        printf("\n\n\n\n\n是否继续游戏?\n1.继续。\n2.退出\n");    scanf("%d",&a);
        }while(a==1);
        c:
        while(b>=0)
            {
                system("cls");
                system("color 60");
                printf("\n\n\n\n\n\n\n\n\n\n\n             欢迎客官下次光临,%d秒后退出游戏",b);
                Sleep(1000);
                b=b-1;
             }

         return(0);/*结束语*/   
     }

[此贴子已经被作者于2021-7-16 16:22编辑过]

收到的鲜花
  • 王牌疯姐姐2021-07-17 15:51 送鲜花  1朵   附言:兄弟辛苦你了
搜索更多相关主题的帖子: system printf 游戏 积分 color 
2021-07-16 15:45
王牌疯姐姐
Rank: 1
来 自:湖南
等 级:新手上路
威 望:2
帖 子:8
专家分:0
注 册:2021-7-17
收藏
得分:0 

唱反调是我的本性,出其不意是我的个性。
2021-07-17 15:49
快速回复:一篇由满屏 printf 和 if 组成的猜猜猜文字游戏
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021465 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved