| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 341 人关注过本帖
标题:刚了一个晚上,终于刚出来了,然而有一个大bug,随时会退出,怎么解决啊
只看楼主 加入收藏
西交利物浦
Rank: 1
来 自:荷兰 郑姆斯特丹
等 级:新手上路
帖 子:26
专家分:0
注 册:2015-11-19
结帖率:100%
收藏
 问题点数:0 回复次数:3 
刚了一个晚上,终于刚出来了,然而有一个大bug,随时会退出,怎么解决啊
#include<stdio.h>
#include<windows.h>
#include<stdlib.h>
#include<time.h>
int main(void)
{
    int origin[16],i,m,l,r,p[4][4],(*pair)[4],j,x=0,y=9;
    char (*cover)[4],c[4][4]= {{'?','?','?','?'},{'?','?','?','?'},{'?','?','?','?'},{'?','?','?','?'}};
    srand((unsigned)time(NULL));
    for(i=0; i<8; i++)
    {
        origin[i]=origin[i+8]=(rand()%(y-x))+x;
        x+=10;
        y+=10;
    }
    for(i=0; i<30; i++)
    {
        l=rand()%16;
        r=rand()%16;
        m=origin[l];
        origin[l]=origin[r];
        origin[r]=m;
    }
    i=0;
    for(pair=p; pair<p+4; pair++)
    {
        for(j=0; j<4; j++)
        {
            (*pair)[j]=origin[i];
            printf("%4d",(*pair)[j]);
            i+=1;
        }
        printf("\n");
    }
    Sleep(10000);
    system("cls");
    for (cover = c; cover < c+4; cover++)
    {
        for (i = 0; i < 4; i++)
        {
            printf("%4c",(*cover)[i]);
        }
        printf("\n");
    }
    int a,b,e,f,t=0,pairs=8;
    while(pairs>0)
    {
        printf("Please select a position (or coordinate) of number: ");
        scanf("%d %d", &a, &b);
        printf("Please select another one you think is the pair of previous one: ");
        scanf("%d %d", &e, &f);
        c[a-1][b-1]=p[a-1][b-1];
        c[e-1][f-1]=p[e-1][f-1];
        t+=1;
        for (cover = c; cover < c+4; cover++)
        {
            for (i = 0; i < 4; i++)
            {
                if((*cover)[i]=='?')
                {
                    printf("%3c",(*cover)[i]);
                }
                else
                {
                    printf("%3d",(*cover)[i]);
                }
            }
            printf("\n");
        }
        Sleep(2500);
        system("cls");
        if(p[a-1][b-1]==p[e-1][f-1])
        {
            pairs-=1;
            for (cover = c; cover < c+4; cover++)
            {
                for (i = 0; i < 4; i++)
                {
                    if((*cover)[i]=='?')
                    {
                        printf("%3c",(*cover)[i]);
                    }
                    else
                    {
                        printf("%3d",(*cover)[i]);
                    }
                }
                printf("\n");
            }
        }
        else
        {
            c[a-1][b-1]='?';
            c[e-1][f-1]='?';
            for (cover = c; cover < c+4; cover++)
            {
                for (i = 0; i < 4; i++)
                {
                    printf("%3c",(*cover)[i]);
                }
                printf("\n");
            }
        }
    }
    printf("Congratulation! It took you %d times to find all pairs.",t);
    return 0;
}
2015-11-22 13:43
西交利物浦
Rank: 1
来 自:荷兰 郑姆斯特丹
等 级:新手上路
帖 子:26
专家分:0
注 册:2015-11-19
收藏
得分:0 
2015-11-22 13:43
西交利物浦
Rank: 1
来 自:荷兰 郑姆斯特丹
等 级:新手上路
帖 子:26
专家分:0
注 册:2015-11-19
收藏
得分:0 
找不到问题啊
2015-11-22 13:44
西交利物浦
Rank: 1
来 自:荷兰 郑姆斯特丹
等 级:新手上路
帖 子:26
专家分:0
注 册:2015-11-19
收藏
得分:0 
2015-11-22 14:04
快速回复:刚了一个晚上,终于刚出来了,然而有一个大bug,随时会退出,怎么解决啊 ...
数据加载中...
 
   



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

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