| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 365 人关注过本帖
标题:我的程序我在VC上运行不了。谁能帮忙看看错哪了啊。拜托了
只看楼主 加入收藏
lcp602831168
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-11-30
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
我的程序我在VC上运行不了。谁能帮忙看看错哪了啊。拜托了
#define UP 0x4800
#define DOWN 0x5000
#define LEFT 0x4b00
#define RIGHT 0x4d00
#include"conio.h"
#include"time.h"
#include"stdlib.h"
int k[17][24]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,1,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,
0,1,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,0,0,
0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,
0,3,1,1,1,1,0,1,1,1,4,1,0,1,0,1,1,1,1,1,1,1,0,0,
0,1,0,0,1,0,1,0,0,0,0,1,0,1,1,1,0,0,0,0,0,0,0,0,
0,2,1,1,1,1,6,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,                                                                             
0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,0,
0,1,1,1,1,1,1,1,1,1,1,5,1,1,1,0,1,0,0,1,0,0,0,0,
0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,4,0,0,1,0,0,0,0,
0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,1,1,0,1,1,0,
0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,0,
0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,
0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,1,3,1,1,1,1,1,0,0,
0,2,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,
0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,};
int en(int *b,int n)
{int i;
for(i=0;i<20;i++)
if(b[i]==n)return 0;
return 1;
}
fu(int *b)
{int i;
for(i=0;i<20;i++)
b[i]=0;
}
void lostgame(int num)
{
    textcolor(WHITE);
    gotoxy(11,22);
    cprintf("The sum of the Numbers you have eaten is:%d.",num);
    gotoxy(11,23);
    cprintf("Sorry,you have lost the game!Press any key to restart...");
    getch();
    gotoxy(11,22);
    cprintf("                                                             ");
    gotoxy(11,23);
    cprintf("                                                                  ");
}
void wingame()
{
textcolor(WHITE);
    gotoxy(11,22);
    cprintf("Yeah!Congratulations!You have won the game!");
    gotoxy(11,23);
    cprintf("Press any key to quit...");
    getch();
    window(1,1,25,80);
    textbackground(BLACK);
    textcolor(LIGHTGRAY);
    clrscr();
    exit(0);
}
main()
{
    int i,j,key,num,b[20],p;
    char ch;
aa:
    window(1,1,25,80);
    textbackground(LIGHTGREEN);
    textcolor(YELLOW);
    clrscr();
    fu(b);
    num=0;
    p=0;
    textcolor(LIGHTRED);
    gotoxy(18,1);
    cprintf("%c(UP)%c(DOWN)%c(LEFT)%c(RIGHT)",24,25,27,26);
    gotoxy(16,2);
    cprintf("Eat the numbers in your road whose sum is 7,");
    gotoxy(14,3);
    cprintf("and eat 7 in the end,then you will win the game!");
    textcolor(MAGENTA);
    for(i=4;i<21;i++)
        for(j=20;j<44;j++)
            if(k[i-4][j-20]==0)
            {
                gotoxy(j,i);
                cprintf("%c",219);
            }
            else if(k[i-4][j-40]!=1)
            {
                gotoxy(j,i);
                cprintf("%d",k[i-4][j-20]);
            }
            textcolor(YELLOW);
            i=5;
            j=21;
            gotoxy(j,i);
            cprintf("\1");
            gotoxy(33,5);
            cprintf("7");
            gotoxy(7,7);
            cprintf("num:%d",num);
            textcolor(WHITE);
            gotoxy(11,22);
            cprintf("Press any key to start game,Q key to quit...");
            ch=getch();
            if(ch=='Q'\\ch=='q')
            {
                window(1,1,25,80);
                textbackground(BLACK);
                textcolor(LIGHTGRAY);
                clrscr();
                exit(0);
            }
            else
            {
                textcolor(YELLOW);
                gotoxy(11,22);
                cprintf("                                            ");
            }
            do
            {
                key=bioskey(0);
                sound(200);
                delay(1000);
                nosound();
                swith(key)
                {
                    case DOWN:
                        {
                            if(k[i-4+1][j-20]==0)
                                continue;
                            if(k[i-4+1][j-20]!=1&&k[i-4+1][j-20]!=7&&en(b,i+j+1))
                            {
                                num+=k[i-4+1][j-20];
                                b[p++]=i+j+1;
                                gotoxy(7,7);
                                cprintf("num:%d",num);
                            }
                            textcolor(YELLOW);
                            gotoxy(j,i++);
                            printf("");
                            gotoxy(j,i);
                            cprintf("\1");
                            gotoxy(33,5);
                            if(k[i-4]j-20]==7&&num==7)
                                wingame();
                            else if(num!=7&&k[i-4][j-20]==7)
                            {
                                lostgame(num);
                                goto aa;
                            }
                            break;
                        }
                    case UP:
                        {
                            if(k[i-4-1][j-20]==0)
                                continue;
                            if(k[i-4-1][j-20]!=1&&k[i-4-1][j-20]!=7&&en(b,i+j-1))
                            {
                                num+=k[i-4-1][j-20];
                                b[p++]=i+j-1;
                                gotoxy(7,7);
                                cprintf("num:%d",num);
                            }
                            textcolor(YELLOW);
                            gotoxy(j,i--);
                            printf("");
                            gotoxy(j,i);
                            cprintf("\1");
                            gotoxy(33,5);
                            if(k[i-4][j-20]==7&&num==7)
                                wingame();
                            else if(num!=7&&k[i-4][j-20]==7)
                            {
                                lostgame(num);
                                goto aa;
                            }
                            break;
                        }
                    case LEFT:
                        {
                            if(k[i-4][j-20-1]==0)
                                continue;
                            if(k[i-4][j-20-1]!=1&&k[i-4][j-20-1]!=7&&en(b,i+j-1))
                            {
                                num+=k[i-4][j-20-1];
                                b[p++]=i+j-1;
                                gotoxy(7,7);
                                cprintf("num:%d",num);
                            }
                            textcolor(YELLOW);
                            gotoxy(j--,i);
                            printf("");
                            gotoxy(j,i);
                            cprintf("\1");
                            gotoxy(33,5);
                            if(k[i-4][j-20]==7&&num==7)
                                wingame();
                            else if(num!=7&&k[i-4][j-20]==7)
                            {
                                lostgame(num);
                                goto aa;
                            }
                            break;
                        }
                    case RIGHT:
                        {
                            if(k[i-4][j-20+1]==0)
                                continue;
                            if(k[i-4][j-20+1]!=1&&k[i-4][j-20+1]!=7&&en(b,i+j+1))
                            {
                                num+=k[i-4][j-20+1];
                                b[p++]=i+j+1;
                                gotoxy(7,7);
                                cprintf("num:%d",num);
                            }
                            textcolor(YELLOW);
                            gotoxy(j++,i);
                            printf("");
                            gotoxy(j,i);
                            cprintf("\1");
                            gotoxy(33,5);
                            if(k[i-4][j-20]==7&&num==7)
                                wingame();
                            else if(num!=7&&k[i-4][j-20]==7)
                            {
                                lostgame(num);
                                goto aa;
                            }
                            break;
                        }
                    default:
                        continue;
                        }
                        }while(1);
                        }
搜索更多相关主题的帖子: 运行 
2010-12-01 08:58
cnfarer
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:179
帖 子:3330
专家分:21157
注 册:2010-1-19
收藏
得分:10 
int k[17][24]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,1,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,
0,1,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,0,0,
0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,
0,3,1,1,1,1,0,1,1,1,4,1,0,1,0,1,1,1,1,1,1,1,0,0,
0,1,0,0,1,0,1,0,0,0,0,1,0,1,1,1,0,0,0,0,0,0,0,0,
0,2,1,1,1,1,6,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,                                                                             
0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,0,
0,1,1,1,1,1,1,1,1,1,1,5,1,1,1,0,1,0,0,1,0,0,0,0,
0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,4,0,0,1,0,0,0,0,
0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,1,1,0,1,1,0,
0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,0,
0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,
0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,1,3,1,1,1,1,1,0,0,
0,2,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,
0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,};
先把这个“,”去掉再说!

★★★★★为人民服务★★★★★
2010-12-01 12:40
cc5586228
Rank: 2
等 级:论坛游民
帖 子:7
专家分:10
注 册:2010-11-26
收藏
得分:10 
好多函数都只能在TC下用,而且你这代码数组第一行最后少个逗号,中间有个|| 还写成了//,有个地方还少了个[  ...
2010-12-02 17:33
快速回复:我的程序我在VC上运行不了。谁能帮忙看看错哪了啊。拜托了
数据加载中...
 
   



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

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