标题:各位大佬,抽卡问题怎么写啊,帮帮孩子吧!
取消只看楼主
一个小摆
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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-509245-1-1.html




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

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