| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1412 人关注过本帖
标题:求助。自己写了个八皇后算法,编译的时候出错,C2059: syntax error : ’ba ...
只看楼主 加入收藏
Stephantan
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-10-22
收藏
 问题点数:0 回复次数:1 
求助。自己写了个八皇后算法,编译的时候出错,C2059: syntax error : ’bad suffix on number’
windows XP SP3,VC6.0.

代码如下:
#include <iostream.h>

#define N 8
static char q[N][N];
static int a[N];
static int b[2N-1];
static int c[2N-1];
int s,t;
for(s=0; s <N; s++){
    a[s] = 0;
    for(t = 0; t <N; t++)
        q[s][t] = ’*’;
}
for(s=0; s <2N-1; s++){
    b[s]=c[s]=0;
}
void queen(int n){
    for(int i=n; i>=0; i--){
        if(a==0 && b[N-n+i-1]==0 &&c[n+i-1]==0){
            q[n] = ’Q’;
            a = 1;
            b[N-n+i-1] = 1;
            c[n+i-1] = 1;

            if(n-1>=0){
                queen(n-1);
            }else{
                for(s=0;s <N;s++){
                    for(t=0;t <N;t++)
                        cout < <q[s][t] < <’ ’;
                    cout < <’\n’;
                }
                cout < <’\n’;
            }
            q[n] = ’*’;
            a = 0;
            b[N-n+i-1] = 0;
            c[n+i-1] = 0;
        }
    }
}
错误如下: Compiling...
main.cpp
e:\program files\microsoft visual studio\myprojects\queen_081021\main.cpp(8) : error C2059: syntax error : ’bad suffix on number’
e:\program files\microsoft visual studio\myprojects\queen_081021\main.cpp(8) : error C2143: syntax error : missing ’]’ before ’constant’
e:\program files\microsoft visual studio\myprojects\queen_081021\main.cpp(8) : error C2143: syntax error : missing ’;’ before ’constant’
e:\program files\microsoft visual studio\myprojects\queen_081021\main.cpp(8) : fatal error C1004: unexpected end of file found
搜索更多相关主题的帖子: suffix syntax number bad 
2008-10-22 12:05
Stephantan
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-10-22
收藏
得分:0 
2N应该是2*N,自己改了过来了,但是还是有错,

main.cpp
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(13) : error C2143: syntax error : missing ';' before 'for'
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(13) : error C2143: syntax error : missing ')' before ';'
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(13) : error C2143: syntax error : missing ';' before '<'
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(13) : error C2501: 's' : missing storage-class or type specifiers
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(13) : error C2086: 's' : redefinition
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(13) : error C2143: syntax error : missing ';' before '<'
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(13) : error C2143: syntax error : missing ';' before '++'
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(13) : error C2501: 's' : missing storage-class or type specifiers
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(13) : error C2086: 's' : redefinition
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(13) : error C2143: syntax error : missing ';' before '++'
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(13) : error C2059: syntax error : ')'
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(13) : error C2143: syntax error : missing ';' before '{'
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(13) : error C2447: missing function header (old-style formal list?)
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(19) : error C2143: syntax error : missing ';' before 'for'
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(19) : error C2143: syntax error : missing ')' before ';'
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(19) : error C2143: syntax error : missing ';' before '<'
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(19) : error C2501: 's' : missing storage-class or type specifiers
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(19) : error C2086: 's' : redefinition
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(19) : error C2143: syntax error : missing ';' before '<'
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(19) : error C2143: syntax error : missing ';' before '++'
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(19) : error C2501: 's' : missing storage-class or type specifiers
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(19) : error C2086: 's' : redefinition
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(19) : error C2143: syntax error : missing ';' before '++'
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(19) : error C2059: syntax error : ')'
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(19) : error C2143: syntax error : missing ';' before '{'
E:\Program Files\Microsoft Visual Studio\MyProjects\queen_081021\main.cpp(19) : error C2447: missing function header (old-style formal list?)
Error executing cl.exe.
2008-10-22 14:18
快速回复:求助。自己写了个八皇后算法,编译的时候出错,C2059: syntax error : ...
数据加载中...
 
   



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

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