| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 611 人关注过本帖
标题:前辈们帮我看看,自己在VC6.0是可以运行的,但是提交到学校网站测试就报错了 ...
只看楼主 加入收藏
葫芦小金刚
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2015-5-16
结帖率:0
收藏
已结贴  问题点数:10 回复次数:3 
前辈们帮我看看,自己在VC6.0是可以运行的,但是提交到学校网站测试就报错了,错误详情及代码如下
#include<stdio.h>

void readdata();
void init();
int search();
bool empty_queue();
void addto_queue(int row,int col);
int  takeout_queue();
bool canmoveto(int row,int col,int *r,int *c,int i);
bool isaim(int row,int col);

#define N 12

char Array[12][12];
int start_row,start_col,aim_row,aim_col;
int head,tail,queue[1000],queue_len=1000;

int main()
{
    int step_num;
    readdata();
    init();
    step_num=search();
    printf("%d\n",step_num);
    return 0;
}

int search()
{
    int i;
    int u,row,col,r,c;
    int num;
    while(!empty_queue())
    {
        u=takeout_queue();
        row=u/N;  col=u%N;
        num=Array[row][col];
        for(i=0;i<4;i++)
        {
            if(canmoveto(row,col,&r,&c,i))
            {
                if(isaim(r,c))
                return num+1;
                Array[r][c]=num+1;
                addto_queue(r,c);
            }
        }
    }
    return 0;
}
bool empty_queue()
{
    if(head==tail)
    return true;
    return false;
}
int takeout_queue()
{
    int u;
    u=queue[head++];
    head=head%queue_len;
    return u;
}
bool canmoveto(int row,int col,int *r,int *c,int i)
{
    switch(i)
    {
        case 0: col--; break;
        case 1: row++; break;
        case 2: col++; break;
        case 3: row--; break;
    }
    *r=row;
    *c=col;
    if(row>=0 &&col>=0 &&row<N &&col<N)
    if(Array[row][col]==0)
    return true;
    return false;
}
bool isaim(int r,int c)
{
    if(r==aim_row-1 &&c==aim_col-1)
    return true;
    return false;
}
void addto_queue(int row,int col)
{
    int u;
    u=row*N+col;
    queue[tail++]=u;
    tail=tail%queue_len;
}

void readdata()
{
    int i,j;
    char str[12];
    scanf("%d%d",&start_row,&start_col);
    scanf("%d%d",&aim_row,&aim_col);   
    for(i=0;i<N;i++)
    {
        scanf("%s",str);
        for(j=0;j<N;j++)
        {
            if(str[j]=='.')
            Array[i][j]=0;
            else
            Array[i][j]=1;
        }
    }
}
void init()
{
    head=0;
    tail=1;
    queue[0]=(start_row-1)*N+start_col-1;
}



错误信息:
编译错误:

Main.c
274966\Main.c(6) : error C2061: syntax error : identifier 'empty_queue'
274966\Main.c(6) : error C2059: syntax error : ';'
274966\Main.c(6) : error C2059: syntax error : ')'
274966\Main.c(9) : error C2061: syntax error : identifier 'canmoveto'
274966\Main.c(9) : error C2059: syntax error : ';'
274966\Main.c(9) : error C2059: syntax error : 'type'
274966\Main.c(10) : error C2061: syntax error : identifier 'isaim'
274966\Main.c(10) : error C2059: syntax error : ';'
274966\Main.c(10) : error C2059: syntax error : 'type'
274966\Main.c(51) : error C2061: syntax error : identifier 'empty_queue'
274966\Main.c(51) : error C2059: syntax error : ';'
274966\Main.c(51) : error C2059: syntax error : ')'
274966\Main.c(64) : error C2061: syntax error : identifier 'canmoveto'
274966\Main.c(64) : error C2059: syntax error : ';'
274966\Main.c(64) : error C2059: syntax error : 'type'
274966\Main.c(80) : error C2061: syntax error : identifier 'isaim'
274966\Main.c(80) : error C2059: syntax error : ';'
274966\Main.c(80) : error C2059: syntax error : 'type'

搜索更多相关主题的帖子: 网站测试 include search return 学校 
2015-05-16 10:56
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9008
专家分:53942
注 册:2011-1-18
收藏
得分:4 
自己在VC6.0是可以运行的
------ 不怎么相信,比如你贴的第一个错误 274966\Main.c(6) : error C2061: syntax error : identifier 'empty_queue'
源代码是 bool empty_queue();
C中加入 _Bool 关键字的时候VC6还没发布呢?而且按照C标准,使用bool是要#include <stdbool.h>的,当然,VC不支持。
2015-05-18 09:47
hoy0a1d
Rank: 2
等 级:论坛游民
帖 子:19
专家分:83
注 册:2010-8-1
收藏
得分:4 
typedef int bool;  
#define false 0   
#define true  1

Test.
2015-05-18 16:54
小小少侠
Rank: 2
等 级:论坛游民
帖 子:19
专家分:12
注 册:2015-3-6
收藏
得分:4 
bool empty_queue()
{
    if(head==tail)
    return true;
    return false;
}

bool empty_queue()
{
    if(head==tail)
        return true;
    else
        return false;
}
2015-05-18 22:15
快速回复:前辈们帮我看看,自己在VC6.0是可以运行的,但是提交到学校网站测试就 ...
数据加载中...
 
   



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

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