| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1107 人关注过本帖
标题:各位大佬,抽卡问题怎么写啊,帮帮孩子吧!
取消只看楼主 加入收藏
一个小摆
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2022-6-2
结帖率:0
收藏
已结贴  问题点数:20 回复次数:0 
各位大佬,抽卡问题怎么写啊,帮帮孩子吧!
目前我就写成这个样子。问题是如何将竖列的输出结果改成横向的输出结果,还有一个问题是如何覆盖上一次的抽卡
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
    printf("输入1开始抽卡,输入0结束游戏");
    while (1)
    {
        int n;
        scanf("%d", &n0);
        switch (n)
        {
        case 1:
        {
            int i;
            srand((unsigned)time(NULL));
            for (i = 0; i < 5; i++)
                if (rand() % 1001 - 70 < 0)
                {
                    char u[][11] = { {' ','_','_','_','_','_','_','_','_','_',' '},
                              {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'},
                              {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'},
                              {'|',' ',' ','*',' ',' ',' ','*',' ',' ','|'},
                              {'|',' ',' ','*',' ',' ',' ','*',' ',' ','|'},
                              {'|',' ',' ','*',' ',' ',' ','*',' ',' ','|'},
                              {'|',' ',' ','*',' ',' ',' ','*',' ',' ','|'},
                              {'|',' ',' ',' ','*','*','*',' ',' ',' ','|'},
                              {'|','_','_','_','_','_','_','_','_','_','|'},
                              {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'},
                              {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '} };
                    int e, f;
                    for (e = 0; e < 9; e++) {
                        for (f = 0; f < 11; f++)
                            printf("%c", u[e][f]);
                    printf("\n");   
                    }
                }
                else
                {
                    if (rand() % 1001 - 190 < 0)
                    {
                        char ss[][11] = { {' ','_','_','_','_','_','_','_','_','_',' '},
                                  {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'},
                                  {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'},
                                  {'|',' ','*','*',' ',' ',' ','*','*',' ','|'},
                                  {'|','*',' ',' ',' ',' ','*',' ',' ',' ','|'},
                                  {'|',' ','*','*',' ',' ',' ','*','*',' ','|'},
                                  {'|',' ',' ',' ','*',' ',' ',' ',' ','*','|'},
                                  {'|','*','*','*',' ',' ','*','*','*',' ','|'},
                                  {'|','_','_','_','_','_','_','_','_','_','|'},
                                  {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'},
                                  {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '} };
                        int g, h;
                        for (g = 0; g < 9; g++) {
                            for (h = 0; h < 11; h++)
                                printf("%c", ss[g][h]);
                            printf("\n");   
                        }
                    }
                    else
                    {
                        if (rand() % 1001 - 700 < 0)
                        {
                            char s[][12] = { {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '},
                                              {' ','_','_','_','_','_','_','_','_','_',' '},
                                              {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'},
                                              {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'},
                                              {'|',' ',' ',' ','*','*','*','*',' ',' ','|'},
                                              {'|',' ',' ','*',' ',' ',' ',' ',' ',' ','|'},
                                              {'|',' ',' ',' ','*','*','*',' ',' ',' ','|'},
                                              {'|',' ',' ',' ',' ',' ',' ','*',' ',' ','|'},
                                              {'|',' ',' ','*','*','*','*',' ',' ',' ','|'},
                                              {'|','_','_','_','_','_','_','_','_','_','|'},
                                              {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'},
                                              {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '} };
                            int a, b;
                            for (a = 0; a < 9; a++) {
                                for (b = 0; b < 12; b++)
                                    printf("%c", s[a][b]);
                                printf("\n");   
                            }
                        }
                        else
                        {
                            char r[][12]={{' ','_','_','_','_','_','_','_','_','_',' '},
                                             {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'},
                                              {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'},
                                               {'|',' ',' ','*','*','*','*','*',' ',' ','|'},
                                              {'|',' ',' ','*',' ',' ',' ','*',' ',' ','|'},
                                              {'|',' ',' ','*','*','*','*','*',' ',' ','|'},
                                              {'|',' ',' ','*','*','*',' ',' ',' ',' ','|'},
                                             {'|',' ',' ','*',' ',' ','*',' ',' ',' ','|'},
                                              {'|',' ',' ','*',' ',' ',' ','*',' ',' ','|'},
                                              {'|','_','_','_','_','_','_','_','_','_','|'},
                                              {'|',' ',' ',' ',' ',' ',' ',' ',' ',' ','|'},
                                              {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}};
                            int e, f;
                            for (e = 0; e < 9; e++) {
                                for (f = 0; f < 11; f++)
                                    printf("%c", r[e][f]);
                                printf("\n");   
                            }
                    }
                        }
                        }
                    ;
            break;
        }
        case 0:
        {
            return 0;
        }
        }
    }
}

麻烦各位大佬了,帮我看看怎么改正,谢谢了
搜索更多相关主题的帖子: printf char for int rand 
2022-06-02 14:31
快速回复:各位大佬,抽卡问题怎么写啊,帮帮孩子吧!
数据加载中...
 
   



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

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