| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1093 人关注过本帖
标题:莱鸟向高手请教如何解决 error C2059: syntax error : ';'问题
只看楼主 加入收藏
hcanhong
Rank: 1
来 自:肇庆学院网络工程系
等 级:新手上路
帖 子:58
专家分:0
注 册:2008-9-6
收藏
 问题点数:0 回复次数:0 
莱鸟向高手请教如何解决 error C2059: syntax error : ';'问题
//设A=(a1,a2...,an)和B=(b1,b2...,bn)均为顺序表,比较A与B大小
#include <stdio.h>
#include <stdlib.h>

#define LIST_INIT_SIZE 100
#define OVERFLOW 0
#define LEN sizeof(Sqlist)
typedef struct {
    char *elem;
    int length;
    int listsize;
}Sqlist;

void InitList_Sq(Sqlist *L) {
    /*构造一个空的线性表*/
    L=(Sqlist*)malloc(LEN);
    if (!L) exit(OVERFLOW);
    L->length = 0;
    L->listsize = LIST_INIT_SIZE;
} /*InitList_Sq*/

void Comparison_Sq1(int i, Sqlist *a, Sqlist *b) {
    /*比较a与b大小,其中a与b的元素数目相同*/
    int k;
    
    for(k=0;k<=i;k++;) {
        if (a->elem[k] > b->elem[k]) {
            printf("A>B");break;}//if
        else if (a->elem[k] < b->elem[k]) {
            printf("A<B");break;}//else if
        else if (a->elem[k] == b->elem[k]) {
            if (i==k) printf("A=B");
            else return; }//else
    }//for
} /*Comparison_Sq1*/

void Comparison_Sq2(int i, int j, Sqlist *a, Sqlist *b) {
    /*比较a与b大小,其中a与b的元素数目不相同*/
    int k;

    if(i>j)
        for(k=0;k<=j;k++;) {
            if (a->elem[k] > b->elem[k]) {
                printf("A>B");break;}//if
            else if (a->elem[k] < b->elem[k]) {
                printf("A<B");break;}//else if
            else if (a->elem[k] == b->elem[k]) {
                if (k==j) printf("A>B");
                else return;}//else
        }//for
    else if(i<j)
        for(k=0;k<=i;k++;) {
            if (a->elem[k] > b->elem[k]) {
                printf("A>B");}//if
            else if (a->elem[k] < b->elem[k]) {
                printf("A<B");}//else if
            else if (a->elem[k] == b->elem[k]) {
                if (k==i) printf("A>B");
                else return;}//else
        }//for
}  /*Comparison_Sq2*/

int main(void)
{
    Sqlist *A=NULL, *B=NULL;
    int i=0,j=0;
    char flag[LIST_INIT_SIZE];

    InitList_Sq(A); //构造空表A
    InitList_Sq(B); //构造空表B
    printf("请输入A的字母:\n");
    while(scanf("%c",&flag[i]),A->listsize>i) {
        if(flag) {
            A->elem[i]=flag[i];      
            A->length++;
            i++; }//if
        else break; }//while
    printf("请输入B的字母:\n");
    while(scanf("%c",&flag[j]),B->listsize>j) {
         if(flag) {
            B->elem[j]=flag[j];      
            B->length++;
            j++; }//if
         else break; }//while
    /*比较:*/
    if (i==j) Comparison_Sq1(i, A, B);
    else  Comparison_Sq2(i, j, A, B);
    free(A);/*释放A*/
    free(B);/*释放B*/
    return 0;
}
其中出现的错误为:
E:\数据结构\数据结构题集(C语言版)答案\2.12自己的答案.cpp(26) : error C2059: syntax error : ';'
E:\数据结构\数据结构题集(C语言版)答案\2.12自己的答案.cpp(42) : error C2059: syntax error : ';'
E:\数据结构\数据结构题集(C语言版)答案\2.12自己的答案.cpp(52) : error C2059: syntax error : ';'
        
莱鸟向各位高手请教!!!
搜索更多相关主题的帖子: syntax 
2008-09-07 16:18
快速回复:莱鸟向高手请教如何解决 error C2059: syntax error : ';'问题
数据加载中...
 
   



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

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